Skip to content

Instantly share code, notes, and snippets.

@kenperkins
Created February 3, 2014 18:48
Show Gist options
  • Save kenperkins/8789850 to your computer and use it in GitHub Desktop.
Save kenperkins/8789850 to your computer and use it in GitHub Desktop.
Automatic Git PR alias

For anyone out there on Github projects where devs work on forks and submit PR's to a central repo: This is useful if you want to try out someone's PR from Github without fetching their fork (and all their branches):

1.) In ~/.gitconfig add these lines (if you don't have any aliases already setup):

[alias]
        pr = !git fetch -fu ${2:-REMOTE_REPO_NAME} refs/pull/$1/head:pr/$1 && :

2.) Replace REMOTE_REPO_NAME with the remote name for your project's central repo of course; PR's don't exist on your fork, but on the canonical repository.

3.) > git pr 123 would check out Pull Request #123 as a local branch pr/123 so you can take a look at it.

Credit to Rahman Syed for this tip, a colleague at Rackspace

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