Skip to content

Instantly share code, notes, and snippets.

@oubiwann
Forked from piscisaureus/pr.md
Last active April 26, 2018 15:35
Show Gist options
  • Save oubiwann/9554871 to your computer and use it in GitHub Desktop.
Save oubiwann/9554871 to your computer and use it in GitHub Desktop.
Getting pull request branches for a project

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

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section, e.g.:

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

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
...

To check out a particular pull request:

$ git checkout pr/1002
Branch pr/1002 set up to track remote branch pr/1002 from origin.
Switched to a new branch 'pr/1002'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment