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

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

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


当前回答

我不小心写了和git-extras提供的几乎一样的东西。因此,如果你更喜欢一个自定义命令,而不是安装一堆其他额外的命令,只需将这个git-pr文件放在你的$PATH中的某个地方,然后你可以这样写:

git pr 42
// or
git pr upstream 42
// or
git pr https://github.com/peerigon/phridge/pull/1

其他回答

如果你遵循“github fork”工作流,在这里你创建了一个fork并添加了远程上游回购:

14:47 $ git remote -v
origin  git@github.com:<yourname>/<repo_name>.git (fetch)
origin  git@github.com:<yourname>/<repo_name>.git (push)
upstream        git@github.com:<repo_owrer>/<repo_name>.git (fetch)
upstream        git@github.com:<repo_owner>/<repo_name>.git (push)

要拉入当前分支,你的命令看起来像这样:

git pull upstream pull/<pull_request_number>/head

要拉入一个新的分支,代码看起来像这样:

git fetch upstream pull/<pull_request_number>/head:newbranch

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

git pull origin pull/939/head

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

我不小心写了和git-extras提供的几乎一样的东西。因此,如果你更喜欢一个自定义命令,而不是安装一堆其他额外的命令,只需将这个git-pr文件放在你的$PATH中的某个地方,然后你可以这样写:

git pr 42
// or
git pr upstream 42
// or
git pr https://github.com/peerigon/phridge/pull/1

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

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

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

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

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

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

git checkout $BRANCHNAME

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

git fetch origin pull/2/head:MASTER

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