Skip to content

Instantly share code, notes, and snippets.

@abeger
Last active December 19, 2015 14:39
Show Gist options
  • Save abeger/5970676 to your computer and use it in GitHub Desktop.
Save abeger/5970676 to your computer and use it in GitHub Desktop.
Wrappers for git svn that stash work before the commands and pop them after:
# Little script that stashes outstanding changes, performs an svn dcommit, and pops the stash
git_stashed=0
git diff-index --quiet HEAD > /dev/null
if [ $? -eq 1 ]
then
echo "Stashing current work..."
git stash
git_stashed=1
fi
echo "Committing to svn..."
git svn dcommit
if [ $git_stashed -eq 1 ]
then
echo "Retrieving stashed work..."
git stash pop
fi
# Little script that stashes outstanding changes, performs an svn rebase, and pops the stash
# gsu -f will also perform an svn fetch to get new branches
perform_fetch=0
while getopts ":f" opt
do
case $opt in
f)
perform_fetch=1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
git_stashed=0
git diff-index --quiet HEAD > /dev/null
if [ $? -eq 1 ]
then
echo "Stashing current work..."
git stash
git_stashed=1
fi
echo "Getting latest from svn..."
git svn rebase
if [ $perform_fetch -eq 1 ]
then
echo "Fetching latest branches and tags..."
git svn fetch
fi
if [ $git_stashed -eq 1 ]
then
echo "Retrieving stashed work..."
git stash pop
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment