从同一系统和不同的用户名管理多个github repos

时间:2012-02-11 12:53:48

标签: git github

背景: 我有一个系统,我同样用于业余爱好和办公室项目。我对这两个地方都有不同的github回购。理想情况下,我想要提交不同的用户名。 因此,我创建了repos和本地用户名:git config --local user.name "Local Name"

当推送相同的ssh键时,问题就出现了。如果我更改一个仓库的ssh密钥,它会使我使用相同的ssh密钥推送到其他仓库时遇到麻烦。怎么解决这个问题?

1 个答案:

答案 0 :(得分:0)

假设您使用的是Linux / Unix,则可以将.ssh/config文件配置为指向2个不同的标识

Host foo foo.example.com
Hostname foo.example.com
IdentityFile ~/.ssh/foo_rsa

Host bar bar.example.org
Hostname bar.example.org
IdentityFile ~/.ssh/bar_rsa