How to Port SVN to Git on Mac OS X

tl;dr

sudo gem install svn2git
touch authors.txt
echo "svn_name1 = Firstname Lastname <your.email>" >> authors.txt
mkdir project
cd project
svn info https://svn.example.com/project
svn2git https://svn.example.com/project --verbose --authors ../authors.txt

This was a tricky one. First you need to find out whether the svn module for git is installed. You can do this by running git svn --help. In case it is not installed you can get it by (re-)installing git via homebrew. In case you don’t have homebrew it get gets even trickier, but I found a nice tutorial here.

The next thing you want is svn2git. You can install it via sudo gem install svn2git, which worked effortlessly since ruby and gem were pre-installed.

Now you should create a authors.txt file which maps svn usernames to git names and emails. It looks like this:

svn_name1 = Firstname Lastname <your.email>
svn_name2 = Firstname Lastname <other.email>

Invoke svn2git https://svn.example.com/repo --verbose in a new folder with the URL to your svn repo. I suggest adding --verbose to get some idea about whats happening.

I my case it didn’t work. The reason were the SSL certificate and the password protection of the svn repo. The README suggests adding the username with --username but it did not work. Instead I logged into the repository via svn info https://svn.example.com/repo. There I got prompted to insert my username and password. After that I was asked to accept the certificate. I chose p to accept it permanently.

With the shadow of the login we can now invoke

svn2git https://svn.example.com/repo --verbose --authors /path/to/authors.txt

However, I still got an error: svn2git 'master' did not match any file(s) known to git. To prevent this I added the --rootistrunk flag. Note that this only works after removing the git folder with rm -r .git/ . </other.email></your.email></your.email>


© 2022 Florian Klampfer

Powered by Hydejack v9.1.6