我想检查之前创建的拉请求(通过GitHub web界面创建)。我搜索了一下,发现不同的地方有裁判/拉或裁判/拉/pr

但是当我添加fetch = +refs/pull/*/head:refs/remotes/origin/pr/*到git配置文件并进行git取回时

我哪里做错了?GitHub应该自动创建拉/xyz东西,还是我必须配置一些东西?


当前回答

Github最近发布了一个名为Github -cli的cli实用程序。在安装它之后,你可以使用它的id (doc)在本地签出一个拉请求的分支。

例:gh pr checkout 2267

这也适用于fork,但如果你需要回推到fork,你需要添加远程存储库并使用传统的git推送(直到这个票据在gh实用程序中实现)

其他回答

这将在你不需要命名分支的情况下获取:

git pull origin pull/939/head

如何在我的机器上获得特定的拉取请求?

要获取远程PR到本地回购,

git fetch origin pull/$ID/head:$BRANCHNAME

其中$ID是拉请求ID, $BRANCHNAME是你想要创建的新分支的名称。一旦您创建了分支,那么简单

git checkout $BRANCHNAME

例如,让我们想象一下,你想从源主分支签出拉请求#2:

git fetch origin pull/2/head:MASTER

更多信息请参阅官方GitHub文档。

Github最近发布了一个名为Github -cli的cli实用程序。在安装它之后,你可以使用它的id (doc)在本地签出一个拉请求的分支。

例:gh pr checkout 2267

这也适用于fork,但如果你需要回推到fork,你需要添加远程存储库并使用传统的git推送(直到这个票据在gh实用程序中实现)

你可以使用git config命令来写一个新的规则到.git/config来从存储库中获取pull请求:

$ git config --local --add remote.origin.fetch '+refs/pull/*/head:refs/remotes/origin/pr/*'

然后就是:

$ git fetch origin
Fetching origin
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 4 (delta 2), reused 4 (delta 2), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://github.com/container-images/memcached
 * [new ref]         refs/pull/2/head -> origin/pr/2
 * [new ref]         refs/pull/3/head -> origin/pr/3

将远程公关分支机构导入本地分支机构:

Git获取来源' remote_branch ': ' local_branch_name '

配置本地分支的上游为远端分支。

git分支——set-upstream-to=origin/PR_Branch_Name local_branch

当您想再次将本地更改推到PR分支时

git push origin HEAD:remote_PR_Branch_name