2 min read

svn2git

I'm currently moving our old svn repositories to git. There a lots of reason to do this. Performance, Disk Space, SVN sucks, decentralization and some more.

Here is a Video from Linux Tolvads talking about Git. Tech Talk: Linus Torvalds on git

Tools Used:

I recommand this svn2git tool! It has a good documentation, easy to understand and work almost out of the box!  

Some Words:

I start looking in my local repository from Gentoo.  eix showed  git2svn from http://gitorious.org/svn2git/svn2git . There was a problem running it from our SVN Repo. He wan't able to found some URL part. So it was complete useless. I started  to google a bit. I found some nice links that explain and have some examples. Our svn contains lots of different repositories, i used this link here as a sample. The Script fits  as basic, i adjusted it, so that it fit fine for me. I change it so it can uses SSH to create the Git repositories on a remote Host.  Addtional i created a authors file. Example: stnick = Santa Claus <nicholas@lapland.com>
Code:
#!/usr/bin/env bash
REPOS="project1 project2 project3 project4"
URL="https://10.0.4.7:/Musicpictures"
REMOTE_IP="10.0.4.5"
for repo in $REPOS
do
 echo "Create local repor"
 mkdir $repo
 cd $repo

 echo "Start of svn2git progress"
 cmd="svn2git $URL/$repo -m --authors ../authors.txt"
 echo $cmd
 `$cmd`

 echo "Prepare remote Host with SSH"
 ssh root@10.0.4.5 "mkdir -p /var/git/svn2git/$repo.git && cd /var/git/svn2git/$repo.git && git init --bar"
 cmd="git remote add origin ssh://root@10.0.4.5/var/git/svn2git/$repo.git"
 echo $cmd
 `$cmd`
 cmd="git push --all"
 echo $cmd
 `$cmd`
 cd ..
 echo "DONE EXPORTING $repo"
done
exit

Addtional i change the the verbose and also i add -m for the orgirnal SVN Link, this coaint then also the classic comit ID.

The Main Problem is that not all of the repo are in the default SVN way store, some has no trunk/tags/branches structures. So i have to check that all has been converted in a right way.

Sources:
http://chrisjean.com/2009/02/21/git-project-description-file-hasnt-been-set/