Last active
August 29, 2015 14:16
-
-
Save 4lun/6af04852080792633987 to your computer and use it in GitHub Desktop.
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
# USAGE: | |
# ./svn-to-git.sh http://$svnrepo/ http://$gitrepo/ | |
# | |
# Credit: http://blog.jessitron.com/2013/08/converting-from-svn-to-git.html | |
REPO="$1" | |
echo -e "\nDownloading svn repository and converting to local git repository: '$(basename $REPO)'\nURL: $REPO\n" | |
git svn clone --stdlayout --prefix=svn/ "$REPO" ${REPO##*/} | |
cd "$(basename $REPO)" | |
# Create git branches | |
git for-each-ref refs/remotes/svn --format="%(refname:short)" | sed 's#svn/##' | grep -v '^tags' | while read aBranch; do git branch $aBranch svn/$aBranch; done | |
git branch -D trunk | |
# Create git tags | |
git for-each-ref refs/remotes/svn/tags --format="%(refname:short)" | sed 's#svn/tags/##' | while read aTag; do git tag $aTag svn/tags/$aTag; done | |
git remote add origin "$2" | |
echo -e "\nPushing local git repository '$(basename $REPO)' to new origin\nURL: $2\n" | |
git push -u --all origin | |
git push --tags origin | |
cd .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment