Skip to content

Instantly share code, notes, and snippets.

@andialbrecht
Created May 22, 2012 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andialbrecht/2769093 to your computer and use it in GitHub Desktop.
Save andialbrecht/2769093 to your computer and use it in GitHub Desktop.
git-dance
#!/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