【问题标题】:github cli multiple accountsgithub cli 多个帐户
【发布时间】:2021-04-29 06:57:54
【问题描述】:

我正在尝试使用GitHub CLI

到目前为止,我可以使用它在我们公司的 repo 中列出 PR。

问题是当我尝试通过gh pr checkout 123 结帐 PR 时,123 是 PR 编号。

当我这样做时,我得到了这个错误:

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
exit status 128

显示错误是因为它正在尝试使用git@github.com。但我不使用git@github.com,因为我在 GitHub 上有多个帐户。所以我将我的.ssh/config 设置为:

Host github.com-companyA
    HostName github.com
    User git
    IdentityFile ~/.ssh/companyA

Host github.com-companyB
    HostName github.com
    User git
    IdentityFile ~/.ssh/companyB

我认为解决方法是将git@github.com修改为git@github.com-companyA:foo/bar.git

但我不知道在哪里可以使用 GitHub CLI 修改它。

我在这里的最终目标是检查 PR,在我的本地机器上运行一些测试,然后标记 PR 是否通过。

我可以毫无问题地使用 git 处理项目。我可以推拉就好了。只是我想自动检出 GitHub 上 PR 的分支。我无法控制我的团队如何命名他们的分支。

PS 我工作的公司使用不同的技术,而且两家公司每天都有多个 PR。 我只想要一种自动测试多个 PR 的方法,这样我就不必一个一个地做。 两家公司也在使用GitHub Actions

【问题讨论】:

  • 我知道这一点。这不是我所追求的。我的每个项目的 git 配置都运行良好。只是gh pr checkout好像不行。

标签: git github ssh github-cli


【解决方案1】:

我找到了解决办法。

gh pr list 有一个标志:

-R, --repo [HOST/]OWNER/REPO Select another repository using the [HOST/]OWNER/REPO format

这将列出所有 PR 以及分支名称。 然后我可以使用grep 来获取分支名称。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-14
    • 2018-07-09
    • 2012-12-29
    • 2021-12-20
    相关资源
    最近更新 更多