git - github cli 多个帐户
问题描述
我正在尝试使用GitHub CLI。
到目前为止,我可以使用它在我们公司的 repo 中列出 PR。
gh pr checkout 123
问题是当我尝试通过123
PR 编号来检查 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
.
解决方案
我找到了解决方案。
gh pr list
有一个标志:
-R, --repo [HOST/]OWNER/REPO Select another repository using the [HOST/]OWNER/REPO format
然后,这将列出所有 PR 以及分支名称。然后我可以grep
用来获取分支名称。
推荐阅读
- java - 如何修复棋盘方格不移动到中间
- c++ - C ++:从指针函数返回是正确的地址,但不是正确的内容
- java - Docker 多模块 Maven 构建 - 将所有 POM 文件复制到适当的目录
- spring - 用于执行 GET HTTP 请求的 Spring RestTemplate API 查询参数编码
- android - 未找到“extractApksForDebug”
- android - 完全移除 Android 应用中的操作栏导航栏等
- tfs - 我如何分支?
- matlab - MATLAB GUI:移动绘图点时更新文本框
- javafx-8 - 我的圈子不会显示。我在这里想念什么?
- flutter - 当 Text 小部件不为空时,在 ListTile 中显示标题