The Layout

You can use the flag --stdlayout to tell git svn that standard Subversion directory structure is used --- meaning, in Subversion, you used three directories called trunk, branches, and tags.

With the --stdlayout the final migrated git code will be in just one directory. If you don’t use the above flag, then git will migrate the code into three separate directories (you don’t want that).

When the original SVN repository was not set up with standard names trunk, branches, and tags, you can actually specify these names using the flags --trunk, --tags, and --branches (or, -T, -t, and -b).

Finding the Subversion Repository Layout

By using the ‘svn list’ command, you can find out how the repository has been laid out.

The verbose listing gives the details on when was the last time a particular subdirectory was changed. The date on the tags directory will tell the last time you created a tag (most likely you haven’t changed the source that was copied as a part of a tag creation). Date next to trunk is the date when the trunk was last changed. And the number at the beginning of the listing (e.g. 498) is the last revision that has been made in that particular directory. These revisions in Subversion will become commits in git.

In the above repository, the standard layout of branches, tags, and trunk is used. So, in this case, the flag --stdlayout can be used with the ‘git svn’ command.

Author information

If you don’t provide git svn command, the author information, the user information will be a little bit messed up (or, rather generic).

As you can see, each SVN revision is converted into a commit in git. But the author email address is not correct.

The flag -q (for quiet) provides a one line listing for each revision. This listing includes just the revision number, author name and the date. For most projects, the individual authors can be extracted from this listing manually. Otherwise, a simple script can extract individual authors.

You can also get the above log information in xml format and obtain the author information from there.

In SVN, the revision numbers go from 1, 2, … etc. Where as the commits in git have unique hashes. Once the migration is completed, you can see the 1:1 relationship between revision numbers and commit hashes.

SVN repository location

And, finally, the SVN repository location needs to be provided to the git svn command:

This article talks about migrating a repository from SVN to Git one way – meaning, after the migration, the project is expected to be developed only in Git. It also talks about the cleanup of the migrated Git repository.