我在 GitHub 和 GitLab 中有帐户。我在 GitLab 中生成并添加了一个 RSA key 到我的帐户,但现在我需要在第二个项目中使用 GitHub。
我知道 GitLab 和 GitHub 都使用 git。请告诉我是否可以在一台机器上使用 GitHub 和 GitLab?
最佳答案
是的,您可以,您可以在它们之间共享相同的 key (ssh key )或为每个 git 服务器创建一个新 key 。
创建 SSH 配置文件
When you have multiple identity files(in your case one for gitlab and one for github) , create a SSH config file to store your various identities.
The format for the alias entries use in this example is:
Host alias HostName github.com IdentityFile ~/.ssh/identity
To create a config file for two identities (workid and personalid), you would do the following:
Open a terminal window.
Edit the ~/.ssh/config file.
如果您没有配置文件,请创建一个。
为每个身份组合添加一个别名,例如:
Host github
HostName github.com
IdentityFile ~/.ssh/github
Host gitlab
HostName gilab.com
IdentityFile ~/.ssh/gitlab
通过这种方式,您可以拥有任意数量的帐户,每个帐户都附加一个不同的 ssh key 。
关于git - 可以在一台机器上使用 GitHub 和 GitLab 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40549348/