Skip to content

Instantly share code, notes, and snippets.

@necccc
Last active December 25, 2015 06:29
Show Gist options
  • Save necccc/6932090 to your computer and use it in GitHub Desktop.
Save necccc/6932090 to your computer and use it in GitHub Desktop.
git merge workflow helper
# work branch to feature branch
w2b = "!f() { b=\"$1\"; w=`git status --porcelain -bs|awk 'NR==1{print $2}'`; if [[ ! $w =~ "work" ]]; then echo "Not on a workbranch! Aborting..."; exit 1; fi; git checkout branches/$b; git pull; git merge $w --no-ff; }; if [[ $? == 0 ]]; then git checkout $w; fi; f"
# work branch to feature branch with push
w2bp = "!f() { b=\"$1\"; w=`git status --porcelain -bs|awk 'NR==1{print $2}'`; if [[ ! $w =~ "work" ]]; then echo "Not on a workbranch! Aborting..."; exit 1; fi; git checkout branches/$b; git pull; git merge $w --no-ff; if [[ $? == 0 ]]; then git push; if [[ $? == 0 ]]; then git checkout $w; fi; fi; }; f"
# work branch to master
w2m = "!f() { w=`git status --porcelain -bs|awk 'NR==1{print $2}'`; if [[ ! $w =~ "work" ]]; then echo "Not on a workbranch! Aborting..."; exit 1; fi; git checkout master; git pull; git merge $w --no-ff; if [[ $? == 0 ]]; then git checkout $w; fi; }; f"
# work branch to release tag
w2r = "!f() { r=\"$1\"; w=`git status --porcelain -bs|awk 'NR==1{print $2}'`; if [[ ! $w =~ "work" ]]; then echo "Not on a workbranch! Aborting..."; exit 1; fi; git checkout tags/release-$r; git pull; git merge $w --no-ff; if [[ $? == 0 ]]; then git checkout $w; fi; }; f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment