Git Migrating to Git Migrate from SVN to Git using svn2git


Example

svn2git is a Ruby wrapper around git's native SVN support through git-svn, helping you with migrating projects from Subversion to Git, keeping history (incl. trunk, tags and branches history).

Examples

To migrate a svn repository with the standard layout (ie. branches, tags and trunk at the root level of the repository):

$ svn2git http://svn.example.com/path/to/repo

To migrate a svn repository which is not in standard layout:

$ svn2git http://svn.example.com/path/to/repo --trunk trunk-dir --tags tags-dir --branches branches-dir

In case you do not want to migrate (or do not have) branches, tags or trunk you can use options --notrunk, --nobranches, and --notags.

For example, $ svn2git http://svn.example.com/path/to/repo --trunk trunk-dir --notags --nobranches will migrate only trunk history.

To reduce the space required by your new repository you may want to exclude any directories or files you once added while you should not have (eg. build directory or archives):

$ svn2git http://svn.example.com/path/to/repo --exclude build --exclude '.*\.zip$'

Post-migration optimization

If you already have a few thousand of commits (or more) in your newly created git repository, you may want to reduce space used before pushing your repository on a remote. This can be done using the following command:

$ git gc --aggressive

Note: The previous command can take up to several hours on large repositories (tens of thousand of commits and/or hundreds of megabytes of history).