Matt Smith's Blog

Software Engineering related topics

Fetching GitHub Pull Requests

| Comments

A co-worker was doing some work today to integrate our TeamCity instance integrated with GitHub pull requests. And it got me thinking, I hate adding remotes to my local repo just to pull down pull requests. The solution:

1
2
[alias]
  req = "!f() { git fetch origin refs/pull/$1/head:pr/$1; } ; f"

Usage:

1
2
3
4
5
6
7
8
$ git req 39
remote: Counting objects: 10, done
remote: Compressing objects: 100% (10/10) done.
remote: Total 10 (delta 0), reused 1 (delta 0)
Unpacking objects: 100% (10/10), done.
From github.com:DarthFubuMVC/StoryTeller2
 * [new ref]         reqs/pull/39/head -> pr/39
$ git checkout pr/39

And now I have that pull request locally without adding a remote.

Comments