Skip to content

Instantly share code, notes, and snippets.

@pboehm
Created March 31, 2013 21:26
Show Gist options
  • Save pboehm/5282061 to your computer and use it in GitHub Desktop.
Save pboehm/5282061 to your computer and use it in GitHub Desktop.
# 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