Skip to content

Instantly share code, notes, and snippets.

@RonnyPfannschmidt
Forked from andialbrecht/git-dance.sh
Last active December 17, 2015 19:29
Show Gist options
  • Save RonnyPfannschmidt/5661042 to your computer and use it in GitHub Desktop.
Save RonnyPfannschmidt/5661042 to your computer and use it in GitHub Desktop.
#!/bin/bash
# A hacky command for a common task:
# - stash away all changes in working branch
# - update master from SVN
# - rebase working branch on master
# - flush all committed changes from working branch to master
# - push them to SVN
# - update working branch again
# - patch in changes
WORKING_BRANCH=`git rev-parse --abbrev-ref --symbolic HEAD`
if [ "$WORKING_BRANCH" = "master" ];
then
echo "Already on master.";
exit 1;
fi;
function step {
echo git "$@"
git "$@"
state=$?
if [ $state -ne 0 ];
then
echo "Aborting [$state].";
exit 1;
fi;
}
step stash
step checkout master
step svn rebase
step checkout $WORKING_BRANCH
step rebase master
step checkout master
step pull . $WORKING_BRANCH
step svn dcommit
step checkout $WORKING_BRANCH
step rebase master
git stash pop
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment