My Github pull request workflow

git logo

Let's say I'm taking pull requests for node_redis.

Here's how I go about it.

export NUM=214 # for convenience
curl -s https://github.com/mranney/node_redis/pull/$NUM.patch > $NUM.patch

# see what changed, and make sure it applies cleanly
git apply --stat $NUM.patch
git apply --check $NUM.patch

# add the commits to master
git am --signoff < $NUM.patch

# if I need to make some changes, I do the following and put "e" next
# to the commits that need changes
git rebase -i origin/master

# If there's only one commit in the PR, I use
git commit --amend
# (you should make an alias for this)

Yes, rebase can be scary. I recommend reading about how to undo anything using git's reflog, even a botched rebase or merge.

Update: here are some simpler ways:

export NUM=8
curl -s https://github.com/dtrejo/readmetree/pull/$NUM.patch | git am --signoff

Or even add this to your ~/.gitconfig (via piscisaureus)

[alias]
  # via https://gist.github.com/piscisaureus/3342247
  pullify = config --add remote.origin.fetch '+refs/pull/*/head:refs/remotes/origin/pr/*'

David Trejo

Engineer at Chime & consultant. Past clients include Credit Karma, Aconex, Triplebyte, Neo, the Brown Computer Science Department, Voxer, Cloudera, and the Veteran's Benefits Administration.