Skip to content

Instantly share code, notes, and snippets.

@vnl
Created March 28, 2017 09:31
Show Gist options
  • Save vnl/88e076a857d0455adc0fe292ce4d3d6e to your computer and use it in GitHub Desktop.
Save vnl/88e076a857d0455adc0fe292ce4d3d6e to your computer and use it in GitHub Desktop.
Checkout github pull requests locallly
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 = gitgitgitgit.git
```
Now add the line `fetch = +refs/pull/*/head:refs/remotes/origin/pr/*` to this section.
Kindly change the github url to match your project's URL. It ends up looking like this:
```
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = gitgitgitgit.git
fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
```
Now fetch all the pull requests:
```
$ git fetch origin
From github.com:gitgitgit/node
* [new ref] refs/pull/123/head -> origin/pr/123
* [new ref] refs/pull/133/head -> origin/pr/133
* [new ref] refs/pull/144/head -> origin/pr/144
* [new ref] refs/pull/155/head -> origin/pr/155
...
```
To check out a particular pull request:
```
$ git checkout pr/666
Branch pr/666 set up to track remote branch pr/666 from origin.
Switched to a new branch 'pr/666'
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment