Today I Learned

hashrocket A Hashrocket project

Checkout a Pull Request

Today I learned how to checkout and inspect a Git pull request locally.

Open the .git/config file in the root of the project directory. Locate the [remote "origin"] section, and add this line:

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

Fetch the changes, and you should receive the pull request references:

From github.com:hashrocket/hr-til
 * [new ref]         refs/pull/1/head -> origin/pr/1
 * [new ref]         refs/pull/10/head -> origin/pr/10
 * [new ref]         refs/pull/11/head -> origin/pr/11
...

From here, you can checkout any pull request with git checkout pr/1, git checkout pr/10, etc.

Source: https://gist.github.com/piscisaureus/3342247

See More #git TILs