Created
May 7, 2012 20:47
-
-
Save jproyo/2630306 to your computer and use it in GitHub Desktop.
Git SVN Get and Configure Remote Branch/Tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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