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

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

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


当前回答

假设你的起源和上游信息如下所示

   $ 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_owner>/<repo_name>.git (fetch)
   upstream   git@github.com:<repo_owner>/<repo_name>.git (push)

分行的名字是

   <repo_owner>:<BranchName>

then

   git pull origin <BranchName>

应该做这项工作

其他回答

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

虽然这个线程上的大多数答案都可以工作,但我更喜欢在新的分支中获取一个pull请求,并对旧的提交进行软重置(将PR更改移动到staging区域),这允许我测试以及查看我的IDE中的差异。

git fetch origin pull/<PR-id>/head:<BRANCH_NAME>
git checkout BRANCH_NAME

然后对旧的提交进行软重置(参见使用git log的提交列表)

git reset --soft <hash_of_old_commit>

e.g

git fetch origin pull/65/head:test-branch 
git checkout test-branch
git log # press 'q' to exit
git reset --soft 7d7fe166cd878ed70c559c4e98faf2323532

运行上述命令将提取PR的更改,并将它们显示在您的IDE版本中,它们不会被提交,您可以在登台区域中看到差异(就像这些更改是在本地进行的一样)。

参考:Github文档参考

创建本地分支

git checkout -b local-branch-name

拉遥控器PR

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

我不小心写了和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