【问题标题】:Github: How can I push to an organization's repo that I don't have permissions to cloneGithub:如何推送到我无权克隆的组织的存储库
【发布时间】: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时,我指向的是第一个账号,它没有组织权限。

标签: git github


【解决方案1】:

我通过以下方式修复它:

  1. 重新添加 id_rsa_second
  2. 检查ssh -T git@github-second 并确保它指向second-account
  3. git remote add origin git@github-second:second-account/org-repo.git
  4. git remote add upstream git@github-second:org-account/org-repo.git
  5. 向上游推送。 希望这对其他人有所帮助。

【讨论】:

  • 很高兴看到这一点。恭喜:)
猜你喜欢
  • 2022-01-17
  • 2021-10-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-30
  • 1970-01-01
  • 2016-10-09
相关资源
最近更新 更多