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

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

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


当前回答

我正在使用hub,一个来自github的工具:https://github.com/github/hub

使用hub在本地检出一个pull请求有点容易:

hub checkout https://github.com/owner/repo/pull/1234
or
hub pr checkout 1234

其他回答

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

git pull origin pull/939/head

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

创建本地分支

git checkout -b local-branch-name

拉遥控器PR

git pull git@github.com:your-repo-ssh.git remote-branch-name

对于Bitbucket,你需要将pull替换为pull-requests。

首先,你可以通过git ls-remote origin命令确认pull request URL样式。

$ git ls-remote origin |grep pull
f3f40f2ca9509368c959b0b13729dc0ae2fbf2ae    refs/pull-requests/1503/from
da4666bd91eabcc6f2c214e0bbd99d543d94767e    refs/pull-requests/1503/merge
...

正如你所看到的,它是refs/pull-requests/1503/from而不是refs/pull/1503/from

然后你可以使用任何答案的命令。

我更喜欢在不创建本地分支的情况下提取和签出,并且处于HEAD分离状态。它允许我快速检查拉取请求,而不会用不必要的本地分支污染本地机器。

git fetch upstream pull/ID/head && git checkout FETCH_HEAD

其中ID是一个拉请求ID,上游是已经创建的原始拉请求(例如,它可以是origin)。

如果你使用Github.com,转到“拉请求”,点击相关的拉请求,然后点击“命令行说明”链接: