【发布时间】:2021-11-16 19:51:31
【问题描述】:
我有两个 github 帐户。我已经为两者创建了 SSH 密钥,并相应地配置了它们。我知道我的配置可以正常工作,因为我可以将我的个人存储库推送到两个帐户。 示例配置
Host github.com
etc
IdentityFile: id_rsa
Host github-second
etc
IdentityFile: id_rsa_second
要为我的普通帐户添加遥控器,我使用
git remote add origin git@github.com:account/repo.git
要为第二个帐户添加遥控器,我使用
git remote add origin git@github-second:second-account/other-repo.git
我现在是拥有第二个帐户的组织的成员。
感兴趣的 repo 的 url 看起来像 github.com/organization/org-repo 与 github.com/second-account/org-repo。
我尝试使用以下方法添加 org 存储库:
git remote add origin git@github-second:organization/org-repo
我确实在我的本地机器上得到了 repo 文件。但是,我无法推送到 org repo。
错误:
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.```
I have contacted the organization and they said that I have full write access.
I am not sure what else to try.
【问题讨论】:
-
试试
git remote add origin git@github.com:second-account/other-repo.git,如果你的repos都在github上。 -
@Niloct 我也试过了。但是为了进行健全性检查,我又试了一次。我得到同样的错误。我也试过:
git remote add origin git@github:second-account/organization/org-repo.git无济于事。 -
git@github-second:没有意义,github-second是托管 git 存储库的域,您的问题点应该是github.com。 -
@Niloct 我的理解是不同的 github 帐户在配置中应该有不同的主机,但主机名可以相同(github.com)。 id_rsa 应该不同。由于组织权限在第二个账号上,所以我认为当我使用
git@github.com时,我指向的是第一个账号,它没有组织权限。