git-gh-merge allows you to merge a GitHub pull request from the command line.
If you have multiple email addresses on GitHub, merging locally has the advantage that the merge commit will be from your local/correct email, instead of the primary email of your GitHub account.
cd path/to/your/repo
git gh-merge 71 # 71 is the pull request number
The script performs the same actions as GitHub's "Merge" button, including deleting the local and remote branches when successfully merged.
Here is the example output from a merge:
$ git gh-merge 75
Merging pull request 75 of uber/ringpopd-go into master: "Fix swim file descritor leak"
Continue? [y/N] y
+ git checkout fix/swim-test-fd-leak
Already on 'fix/swim-test-fd-leak'
Your branch is up-to-date with 'origin/fix/swim-test-fd-leak'.
+ git branch -u origin/fix/swim-test-fd-leak fix/swim-test-fd-leak
Branch fix/swim-test-fd-leak set up to track remote branch fix/swim-test-fd-leak from origin.
+ git pull
Already up-to-date.
+ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
+ git pull
Current branch master is up to date.
+ git merge --no-ff fix/swim-test-fd-leak -m 'Merge branch '\''fix/swim-test-fd-leak'\''
Closes #75'
Merge made by the 'recursive' strategy.
swim/stats_test.go | 8 --------
swim/test_utils.go | 13 ++++++++++---
2 files changed, 10 insertions(+), 11 deletions(-)
+ git push
Counting objects: 1, done.
Writing objects: 100% (1/1), 245 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
To ssh://[email protected]/uber/ringpop-go
beb0ed6..ad683a8 master -> master
+ git branch -d fix/swim-test-fd-leak
Deleted branch fix/swim-test-fd-leak (was 22dcbab).
+ git push origin :fix/swim-test-fd-leak
To ssh://[email protected]/uber/ringpop-go
- [deleted] fix/swim-test-fd-leak
$
The commands being executed are printed as you go and execution halts if any command fails so you can fix the problem and try again.
To install, download git-gh-merge
somewhere into your $PATH
. E.g. to
install to /usr/local/bin
:
wget -O /usr/local/bin/git-gh-merge \
https://gist.githubusercontent.com/dansimau/e69c8e610c822c97ba04/raw/git-gh-merge && \
chmod +x /usr/local/bin/git-gh-merge
Based off this gist by jamesarosen.
MIT