Migrating a svn repository to git

2016/01/11

Tags: svn to git import svn folder to git git svn

I realize there are a ton of articles about migrating from svn to git, but this is mostly a note so I don’t forget the steps. My situation is a bit particular since I need to import an svn folder to git.

The simplest way seems to be using svn2git. I’ve used used git-svn and SubGit, but to no avail.
The steps are as follows:

    sudo apt-get install ruby
    sudo apt-get install rubygems
    sudo gem install svn2git
    mkdir my_new_repo
    cd my_new_repo

At this point we have installed svn2git and set up the folder in which we’ll import our repo.
Next, is the magic one-liner which does all the work:

    svn2git <svn repo> --rootistrunk --nobranches --notags --username <svn username> --authors <authors file>

This will take a while.
After the operation is completed, you will have in the my_new_repo directory, a local git repository with all the contents of the svn repo, including history. No branches or tags, just the trunk.
Next you should push the contents to a remote repository:

    git remote add origin <remote repository url>
    git push origin master

And that is all.