Skip to content

Instantly share code, notes, and snippets.

@Cadair
Forked from piscisaureus/pr.md
Last active March 31, 2016 13:51
Show Gist options
  • Save Cadair/bad5c69c3aa075a34d65 to your computer and use it in GitHub Desktop.
Save Cadair/bad5c69c3aa075a34d65 to your computer and use it in GitHub Desktop.

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "upstream"]
	fetch = +refs/heads/*:refs/remotes/upstream/*
	url = git@github.com:sunpy/sunpy.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/upstream/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

[remote "upstream"]
	fetch = +refs/heads/*:refs/remotes/upstream/*
	url = git@github.com:sunpy/sunpy.git
	fetch = +refs/pull/*/head:refs/remotes/upstream/pr/*

Now fetch all the pull requests:

$ git fetch upstream
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'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment