Skip to content

Instantly share code, notes, and snippets.

@jproyo
Created May 7, 2012 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jproyo/2630306 to your computer and use it in GitHub Desktop.
Save jproyo/2630306 to your computer and use it in GitHub Desktop.
Git SVN Get and Configure Remote Branch/Tag
#!/bin/bash
usage()
{
echo "This script get a specific branch/tag from SVN through git-svn and config in your .git/config ref."
echo "OPTIONS:"
echo " -h Show help"
echo " -t Tag Name that we want to label our branch localy"
echo " -u SVN Tag URL"
}
TAG_NAME=
URL_TAG=
while getopts ht:u: flag; do
case $flag in
h)
usage
exit 1
;;
u)
URL_TAG=$OPTARG
;;
t)
TAG_NAME=$OPTARG
;;
esac
done
if [ -z $TAG_NAME ] || [ -z $URL_TAG ]; then
usage
exit 1
fi
echo "Getting Branch $TAG_NAME from $URL_TAG"
git config --add svn-remote."$TAG_NAME".url "$URL_TAG";
git config --add svn-remote."$TAG_NAME".fetch :refs/remotes/"$TAG_NAME";
git svn fetch "$TAG_NAME";
git checkout -b local-"$TAG_NAME" -t "$TAG_NAME";
git svn rebase "$TAG_NAME";
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment