git - 管理来自同一系统和不同用户名的多个 github 存储库

标签 git github

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

当推送相同的 ssh key 对两个 repos 都不起作用时,问题就出现了。如果我更改一个存储库的 ssh key ,使用相同的 ssh key 推送到另一个存储库会给我带来麻烦。如何解决?

最佳答案

假设您使用的是 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

关于git - 管理来自同一系统和不同用户名的多个 github 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9240358/

相关文章:

git - 脏/干净的工作目录是什么意思?

git子模块更新 "no-fetch"

git - merge 冲突解决

git - 为什么我不能推送我的新分支?

git - 如何重命名分支以删除大写?

git - "Could not find any relevant repository hosts for the currently open repository"

git - 与多个用户一起使用 Git SVN 和远程 Git 存储库的工作流程

git - 如何从另一个分支(开发)更新我的工作 Git 分支?

docker - 如何在 Github Action 上登录 pull registry for services

git - 检查提交哈希是否已部署在 git 中