How do I migrate an SVN repository to a GIT repository?
January 29, 2012 in GIT, Recipes, Subversion, Version Control
We will illustrate this procedure using a simple example.
The following steps have been validated on Mac OS X Snow Leopard, but I presume they are valid in general. Note also that this discussion follows closely some of the ideas described on this post on StackOverflow.
First of all make sure you have installed git svn. If you don’t, you can install it using MacPorts:
sudo port install git-core +svn
For more information refer to the great simple discussion by Stephen Bannasch which can be found here.
Now let’s cd to the directory where you checked out your local SVN repository that you want to move in a GIT repository. Note that this directory is often referred to as the working copy root path. In my case, issuing the command
svn info
I obtain the following information:
Path: . Working Copy Root Path: /Users/zuliani/Documents/Research/ImageWarping URL: file://localhost/Volumes/Storage/SVNRepository/Research/ImageWarping Repository Root: file://localhost/Volumes/Storage/SVNRepository Repository UUID: 876389e7-766b-4580-87e5-4a53071d1477 Revision: 44 Node Kind: directory Schedule: normal Last Changed Author: zuliani Last Changed Rev: 44 Last Changed Date: 2010-12-05 20:00:06 -0800 (Sun, 05 Dec 2010)
The URL points to the remote repository where the SVN database with all the revisions is hosted. In my case it resides in the volume Storage, specifically at /SVNRepository/Research/ImageWarping. This information will be used later. Let’s create the directory for the remote GIT repository. In my case it will be created by the command:
mkdir -p /Volumes/Storage/GITRepository/Research/ImageWarping
We will then cd into such directory and init the repository:
git init --bare
Let’s now create the directory where the new local GIT repository will be created:
mkdir -p ~/Documents/Temp/ImageWarping
Now let’s cd to the newly created directory that will host the local GIT repository and let’s initialize the GIT repository from the remote SVN repository (whose location was found in the URL shown before):
git svn init file://localhost/Volumes/Storage/SVNRepository/Research/ImageWarping
Let’s now fetch all the revisions from the remote SVN repository:
git svn fetch
And now let’s push the local GIT repository to the remote one (that we created before) on the master branch:
git remote add origin /Volumes/Storage/GITRepository/Research/ImageWarping git push origin master
We are done! Now we will be able to checkout from the remote repository (origin) simply by issuing the command:
git clone file://localhost/Volumes/Storage/GITRepository/Research/ImageWarping/

thanks for share!