Created
June 12, 2015 12:57
-
-
Save OliverJAsh/db09fea37fa0613737b6 to your computer and use it in GitHub Desktop.
git merge-pr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: git merge-pr [<branch-name>] | |
# ln -s ~/Desktop/git-merge-pr /usr/local/bin | |
# | |
# Merge the PR for a given branch, and delete branches (local and remote) | |
# afterwards. | |
# Defaults to current branch. | |
set -e | |
BRANCH=`git rev-parse --abbrev-ref HEAD` | |
HEAD=${1:-$BRANCH} | |
BASE=${2:-master} | |
git log --oneline $BASE..$HEAD | |
echo | |
read -p "Merge $HEAD into $BASE?" | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
echo | |
git checkout $BASE \ | |
&& git pull \ | |
&& echo "Merge" \ | |
&& git merge --no-edit $HEAD \ | |
&& git push \ | |
&& echo "Delete branches" \ | |
&& git branch -d $HEAD \ | |
&& git push origin :$HEAD | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment