Using svn2git to preserve tags & branches

Sometime back we moved from SVN to Git. We had 600 repos in SVN so it was a tedious work!

Below is the process we used to speed up things.

Convert SVN username to Git Equivalent

In our case, our SVN usernames were in format firstname.lastname and email addresses are in format [email protected].

So we used a script from here.

#!/usr/bin/env bash 
authors=$(svn log -q http://path/to/root/of/project | grep -e '^r' | awk 'BEGIN { FS = "|" } ; { print $2 }' | sort | uniq) 
for author in ${authors}; do 
    echo "${author} = ${author} <${author}@rtcamp.com>"; 
done

We pasted output in a file at ~/.svn2git/authors 

This authors file has line for every SVN user. Just open it once to make sure if it needs any correction.

firstname.lastname = firstname.lastname <[email protected]

Install svn2git

If you do not have ruby/git then run first…

sudo apt-get install git-core git-svn ruby rubygems

Then…

sudo gem install svn2git --source http://gemcutter.org

Moving a SVN repo to Git (and GitHub)

Create a dir for svn-git conversion locally:

mkdir /tmp/migration/ && cd /tmp/migration/

Run svn2git

Use a syntax like below. <URL> is your SVN repo URL.svn2git is optimised for conventional SVN layout which includes tags, trunk and branches. If you run it correctly, it will convert all SVN branches to git branches, SVN tags to git tags and SVN trunk to git master.

You can check svn2git github project for more info.

When tagsbranchestrunk – all 3 are present

svn2git <URL> --no-minimize-url --verbose

When branches is missing

svn2git <URL> --no-minimize-url --verbose --nobranches

When tags is missing

svn2git <URL> --no-minimize-url --verbose --notags

When tags & branches both is missing

svn2git <URL> --no-minimize-url --verbose --notags --nobranches

When tagsbranchestrunk – all 3 are missing

svn2git <URL> --no-minimize-url --verbose --rootistrunk

3 responses to “Using svn2git to preserve tags & branches”

  1. After migrating the repo where can i check if the migration is successful or not using linux command.

  2. This commands showing as migration is successful but we are unable to find where this has been stored.