That gist does describe what happend when you do a git fetch:
Obviously, change the github url to match your project's URL. It ends up looking like this:
[remote "origin"]
url = [email protected]:joyent/node.git
fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
fetch = +refs/heads/*:refs/remotes/origin/*
Note the order of fetch
refspecs, as suggested in the comments by crashneb, in his own's answer.
If not, meaning if you don't have the right order because of a:
git config --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*" ...
and then trusted the PR-checkout to naturally setup the new local branch with something like git switch pr/1
-- then you might have trouble should the PR get updated and you want to just git pull
it again.
The branch.pr/1.merge
config value will not be correct.
Now fetch all the pull requests:
$ git fetch origin
From github.com:joyent/node
* [new ref] refs/pull/1000/head -> origin/pr/1000
* [new ref] refs/pull/1002/head -> origin/pr/1002
* [new ref] refs/pull/1004/head -> origin/pr/1004
* [new ref] refs/pull/1009/head -> origin/pr/1009
...
To check out a particular pull request:
$ git checkout pr/999
Branch pr/999 set up to track remote branch pr/999 from origin.
Switched to a new branch 'pr/999'
You have various scripts listed in issues 259 to automate that task.
The git-extras project proposes the command git-pr
(implemented in PR 262)
git-pr
(1) -- Checks out a pull request locally
SYNOPSIS
git-pr <number> [<remote>]
git-pr clean
DESCRIPTION
Creates a local branch based on a GitHub pull request number, and switch to that branch afterwards.
The name of the remote to fetch from. Defaults to origin
.
EXAMPLES
This checks out the pull request 226
from origin
:
$ git pr 226
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 12 (delta 3), reused 9 (delta 3)
Unpacking objects: 100% (12/12), done.
From https://github.com/visionmedia/git-extras
* [new ref] refs/pull/226/head -> pr/226
Switched to branch 'pr/226'