Migrating SVN repository to Git

3 steps to migrate a SVN repository to Git

Posted by Abdel Kamel on January 18, 2017

Recently I was tasked with migrating a SVN repository with 10 years of commit history to Git. It turned out to be much simpler then I had anticipated. Here are the steps I took to accomplish this task.

Step 1

Create and init an empty Git repository on Github or Gitlab.

Step 2

Clone your SVN repository using the git svn command.

git svn clone --stdlayout --username=<svn_account_username> 'http://location-of-svn-repository/trunk' tmp

If wish not to clone all the history in your svn repository just add the revision flag along with the revision number like so --revision=123456

Depending on the amount of history you have in your SVN repository and the number of branches, this can take hours to complete. Time for some ☕☕

Step 3

Once the svn clone command completes, your a ready to push up the history along with the new git repository.

cd tmp
git remote add origin git@remote-git-repository-address
git push origin master

Thats it! All done.

comments powered by Disqus