Monday, June 17, 2013

Just Another HOWTO on Subversion-to-Git Conversion

I found many blogs detailing how to do this -- each tailored for different circumstances, some working, some producing strange error messages. Here is the workflow I used -- bare in mind, my SVN repositories are _very_ simple, contain no branches, no tags, and only I committed to them.

Set Up authors-transform.txt

This file is used to map SVN users to Git committers. The authors-transform.txt file should be plain text, containing lines like:
joe = Joe Smith <joe@smith.com>
jane = Jane Smith <jane@smith.com>

Clone the Subversion Repository

git svn clone <Subversion_URL> --no-metadata -A ~/authors-transform.txt --stdlayout
 Note: the URL should not contain "trunk".

Manual Fixes

The git svn clone creates a bidirectional repository, ie you can commit your changes back to SVN, and also make further updates. This is not what we want here - we want to migrate away from SVN for good.

The fixes I like to do manually:
  • create .gitignore file (use svn propget svn:ignore on a checked out svn rep)
  • check unhandled stuff in .git/svn/refs/remotes/trunk/unhandled.log -- e.g. keywords ($Id$, etc) are not supported by git
  • remove links to the Subversion repository (more might be needed, check your .git directory sturcture):
    • rm .git/refs/remotes/trunk
    • rm -r .git/svn
    • edit .git/config -- remove Subversion specific parts

Push to a Remote Repository

This part is less related to the topic, just for reference. Assuming you have a different host storing repositories:

[on the remote host] mkdir <git_repo_dir>; git init --bare <git_repo_dir>
[on the local host] git remote add origin <user>@<host>:<git_repo_dir>; git push -u origin master



No comments:

Post a Comment