git - 可以在一台机器上使用 GitHub 和 GitLab 吗?

标签 git ubuntu github gitlab

我在 GitHubGitLab 中有帐户。我在 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/

相关文章:

Git for Websites/post-receive/测试和生产站点分离

git - 如何在git中恢复对特定类型文件的未提交更改

c# - 由 Visual Studio 2015 创建的 C# 程序的哪些文件值得提交到存储库中?

git - merge 冲突 Git

git - 在 GitHub 中,更新一个分支以匹配另一个分支

linux - 如何更新 Ubuntu 中当前目录下的所有文件,并在文件开头添加一些注释

linux - (ONIE) stg : command not found and Error 127 in Ubuntu terminal

java - JDBC 连接到 MySQL 需要哪些文件?

git - 在 github 上创建单个提交的 pull 请求

android - 如何在 Android Arsenal 上发布 Android Library?