svn to git

Here is a quick way to migrate a subversion repository to git.

1
2
3
4
$ mkdir my-repo
$ cd my-repo
$ git svn init --stdlayout https://www.example.com/svn/my-repo
$ git svn fetch --authors-file=authors.txt

That's pretty much it. my-repo is now a fully functional git repository.

Notes:

  • This is for a subversion repository that contains one project and have the standard trunk/tags/branches layout.

    • If you have a different layout, on line 3 replace --stdlayout with something like -t tags -b branches -T trunk (and replacing tags/branches/trunk by their actual values).
    • If you have several projects you need to filter them out from subversion (dump/filter/load filtered dump in a new repository).
  • Line 3 also works if you have your repository locally, replace the repository URL with the actual path: git svn init --stdlayout file:///path/to/repository.

  • On line 4 --authors-file is optional. This option tells git to remap svn commit authors to something else, example of an authors.txt file:

    username = User Name <user.name@example.com>
    foobar = Foo Bar <foo.bar@example.com>
    

Comments Add one by sending me an email.