Importing a Subversion repo into Git

To import a svn repo create a new git repo and run

git svn clone project -s

Then once your done, repack it.

git gc project/

SVN Branches

If you wish to also map your branches, you may run something like the following

for a in `cat .git/packed-refs |grep remotes |grep -v pack-refs |grep -v tags |grep -v trunk |grep -v '@'|awk '{print $2}'`
   b=`echo "$a" |sed 's/\// /g' |awk '{print $3}'`
   git branch -t $b $a

SVN Tags

From a checked out SVN directory, the following will give you a list of all the users in the SVN log. You will still need to updated this list before you may use it.

for a in `cat .git/packed-refs |grep remotes |grep tags |grep -v '@' |awk '{print $2}'`
   b=`echo "$a" |sed 's/\// /g' |awk '{print $4}'`
   echo "creating tag $b"
   git tag -a $b -m "Converting SVN tag to GIT tag" $a
   sleep 5

SVN Authors list

#!/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} = ${author} ";

Once you have your list built, need to add it to your .git config. I store my authors file in the .git directory.

     authorsfile = .git/authors