One of the common tasks of the opensource project maintainer role is dealing with pull requests.

You won’t see me clicking that awful green button at GitHub’s web ui. NEVER. I think reviewing contributions is something that needs to be taken seriously and the best way of giving it the due importance is to actually running the code locally, not just spilling ๐Ÿ‘ after a poor glance at the changes.

Let’s be honest here, it’s tempting! ๐Ÿ™‚

Here’s my magic one-liner, which I friendly call pullify (well, not exactly mine, stolen from several parts of the internet, and fitted to my needs, hence mine ๐Ÿ˜› )

git config --global alias.pullify "config --add remote.origin.fetch '+refs/pull/*/head:refs/remotes/origin/pr/*'"
  • cd into a fresh cloned github-hosted project
  • run git pullify
  • run git fetch

now watch the magic happening

remote: Counting objects: 29, done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 29 (delta 6), reused 15 (delta 2)
Unpacking objects: 100% (29/29), done.
From github.com:qmx/aerobot
 * [new ref]         refs/pull/1/head -> origin/pr/1
 * [new ref]         refs/pull/11/head -> origin/pr/11
 * [new ref]         refs/pull/2/head -> origin/pr/2
 * [new ref]         refs/pull/5/head -> origin/pr/5
 * [new ref]         refs/pull/7/head -> origin/pr/7
 * [new ref]         refs/pull/8/head -> origin/pr/8

from now on, you can easily check a pull request by running git checkout -t origin/pr/<pull request no>

now you can go, rebase the branch if needed, and merge it back to master – i tend to ensure we end up with a linear tree, but keeping the branch separated (using git merge --no-ff). In this case if anything goes wrong I can revert a bunch of related commits at once ๐Ÿ™‚

hope you find this useful ๐Ÿ™‚


emergency handle picture taken from here

Source: qmx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s