I created a script for svn to git migration. This script migrates the svn repo to git along with all it's tags and history maintained.
Pre-requisites :
Make sure GIT and SVN are installed on your machine before moving ahead with the migration.
Description for Variables used
SVN_REPO_LINK : http link to where you svn repo is hosted
GIT_REPO_NAME : the name that you want to give to you new git repo
GIT_REPO_LINK : link to your git server where you want to host the repo.
[It is basically a GIT remote that you would want to add]
Authors File :
In svn the commits are associated with the username only, but in git repository email address is also required besides the username. Inorder to maintain the svn commits in git, user emails are are needed. This file serves that purpose.
The format of the file is as follows :
svn user name = Name <email>
Helen_david = Helen David <helen.david@mycompany.com>
RobinR = Robin Rose <robin.rose@mycompany.com>
Script
git svn clone --stdlayout --prefix 'svn/' -A authors.txt $SVN_REPO_LINK $GIT_REPO_NAME
cd $GIT_REPO_NAME
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
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 $GIT_REPO_LINK
git push -u --all origin
git push --tags origin
Now your repository is migrated along with all it's tags,branches and history.