Git Alias for Simplifying Github Pull Requests
As cqlengine has picked up in popularity, so has my need to review pull requests. Here’s the git alias that I’m using:
[alias]
pr = "!f() { git checkout -b pr_$1; curl https://github.com/cqlengine/cqlengine/pull/${1}.patch | git apply -3 - ; }; f "
To use, you simply git pr 51
or whatever the pull request is.
Here’s what it’s doing:
- Creating a branch pr_[pull request number]
- Pulling down the patch
- Piping the patch to apply. The -3 indicates a 3 way merge. If we don’t use this option and we have conflicts, it just sort of fails.
We could optionally do this in our master branch and eliminate the git checkout
portion, then it would simply be a matter of a merge commit & a push to finish things up.