Created
March 31, 2013 21:26
-
-
Save pboehm/5282061 to your computer and use it in GitHub Desktop.
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
# put these lines into your .[bash|zsh]rc file and start a new shell | |
alias feature="git checkout -b" | |
function merge_with_master { | |
branch_name=$(git branch | grep "*" | sed "s/* //") | |
test $branch_name = "master" &&\ | |
echo "Already on master, checkout your feature branch" && return | |
git checkout master | |
grep "origin" .git/config > /dev/null && git pull | |
git merge --ff-only $branch_name && git branch -d $branch_name \ | |
&& echo "You can now 'git push' your code" && return || \ | |
git checkout $branch_name | |
echo "Your are behind master, a clean Merge is not possible!" | |
echo -n "Should I rebase it with master and try it again? (y/n) " | |
read ANSWER | |
[[ -n `echo $ANSWER | grep '^[jyJY]'` ]] && \ | |
git rebase master && merge_with_master | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment