Can I use GitHub and GitLab on the same machine?

I have accounts on GitHub and GitLab . I generated and added the RSA key to my GitLab account , but now I need to work with GitHub in the second project.

I know that GitLab and GitHub use git. Please tell me if it is possible to use GitHub and GitLab on the same machine?

+7
git gitlab github ubuntu
source share
2 answers

Yes, you can share the same key between them (ssh key) or create a new one on git server.

Create SSH configuration file

When you have multiple credentials files (in your case, one for gitlab and one for github), create an SSH configuration file to store the various identifiers.

The format for the aliases used in this example is:

Host alias HostName github.com IdentityFile ~/.ssh/identity 

To create a configuration file for two identifiers (workid and personalid), you must do the following:

 Open a terminal window. Edit the ~/.ssh/config file. 

If you do not have a configuration file, create it.
Add an alias for each combination of identifiers, for example:

 Host github HostName github.com IdentityFile ~/.ssh/github Host gitlab HostName gilab.com IdentityFile ~/.ssh/gitlab 

This way you can have as many accounts as you want, each with a different ssh key attached to it.

+6
source share

Yes, absolutely! Now that you are using ssh as a transport, you have completed half the task.

GitHub and Gitlab are remote (central) repositories. It all depends on the remote that you use to push your commits.

If you created a project on, say, GitHub and cloned it, you will see that the remote (by default origin ) points to the GitHub link. run $ git remote -v inside the project directory to check.

If you want to push the same project on GitLab, all you have to do is add another remote with a different name.

$ git remote add <different-remote-name> <gitlab-remote-link>

Now that you want to update a specific remote, just click on it.

+4
source share

All Articles