Skip to content

Instantly share code, notes, and snippets.

@L1fescape
Last active August 29, 2015 14:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save L1fescape/c6ed954a8e8ee67ad5cd to your computer and use it in GitHub Desktop.
Save L1fescape/c6ed954a8e8ee67ad5cd to your computer and use it in GitHub Desktop.
Check out Pull Requests on a fork

Add the repo you forked from as a remote

Throw this in terminal:

$ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

Setup the repo to track pull requests on the remote

Open up the repo's .git/config.

You should see the following:

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

Append this at the end:

fetch = +refs/pull/*/head:refs/remotes/upstream/pr/*

It should now look like this:

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

Now fetch all the pull requests:

$ git fetch upstream
From https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY
 * [new ref]         refs/pull/1/head -> upstream/pr/1
 * [new ref]         refs/pull/2/head -> upstream/pr/2
 ...

Check out a pull request

$ git checkout upstream/pr/2

Voila!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment