paazmaya.fi

The Website of Juga Paazmaya | Stories about Web Development, Japanese Martial Arts, Hardware prototyping and travelling

Moving version control from Subversion to Git

It was just some …7 years when I got my first touch on version control systems. The first environment was CVS (Concurrent Versions System), but soon it was followed with SVN (Subversion) which was somewhat superior and even today it is developed while CVS is nearly forgotten.

During the recent years there has arisen several other version control systems, such as Git and Mercurial. Perhaps Git has become the most popular, at least when it comes to open source projects, like Qtand FFmpeg. Many of the source hosting efforts, such as Sourceforge and Google Code have added Git to their SCM (Source Code Management) options, where SVN has been for few years.

I have locally used SVN for some years and now trying to move the burden in the cloud, which also seems trendy.

The following transition from local SVN to Git in the cloud is done with:

Firstly there needs to be the _svn2git _package, written in Ruby:

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

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

This will most likely place the script of _svn2git _to _/var/lib/gems/1.8/bin _or something similar, but anyhow not likely in the PATH.

In case there are troubles or even if not, make sure that the packages mentioned in the RubyGems FAQ are installed.

The two following posts were very helpful in order to understand what is happening in the transition:

In my case I copied the SVN repository to my home folder (~/renshuusvn). I was not using the common SVN directory structure (trunk, tags, branches), but instead the repository root was used as a trunk, thus I am passing the option “rootistrunk” to the conversion script.

One more thing to do before issuing the conversion, is to create a list of authors. The format of this text file is the following:

[username in Subversion] = [Name] <[email address]>

In which the name and the email are mine as I was the only one committing, but because of long life span and through many systems, the SVN usernames might have changed. Easy way to get all the SVN usernames is with the following bash script found from technicalpickles.com:

#!/usr/bin/env bash

authors=$(svn log -q | grep -e '^r' | awk 'BEGIN { FS = "|" } ; { print $2 }' | sort | uniq)

for author in ${authors};
 do

  echo "${author} = NAME <USER@DOMAIN>";

done

Once all the authors are listed and saved, the conversion can be issued:

mkdir renshuugit
cd renshuugit
/var/lib/gems/1.8/bin/svn2git file:///home/paazio/renshuusvn \
 --authors ../authors.txt --rootistrunk --verbose

Before publishing the source code, how about removing some unwanted or sensitive data, such as configuration files containing passwords? GitHub has documentation that can help.

Finally pushing the data to the GitHub repository which was created along the way:

git remote add origin git@github.com:GITHUB_USERNAME/REPO_NAME.git

git push origin master

Now the resulting repository for renshuu.paazmaya.fi is available at GitHub.