gitsvngit-svn

git svn clone - How to convert Subversion remotes to Git locals (Windows)


I've attempted to follow the official Git instructions on how to do a one-time, one-way migration of a project from Subversion to Git. I've attempted it a few times, with slightly different options, but I'm not getting the result that I expected.

The instructions suggest that the imported Subversion tags and branches should appear here in the newly created local Git repo after the import procedure is finished:

my-new-local-git-repo\.git\refs\remotes

But the Subversion tags/branches actually exist here:

my-new-local-git-repo\.git\svn\refs\remotes\origin

I suspect that's why the post-import cleanup instructions aren't working for me. I don't know if I've made a mistake in the command/options that I used to execute the import, if the instructions are out-of-date, or if I'm making a mistake elsewhere.

This is the command that I used to create this Subversion-to-Git migrated repo:

git svn clone --stdlayout --authors-file=users.txt http://svn/repo/root/MyProjectInSVN/ new-local-git-repo

Here are some screenshots of what the resulting local Git repo remote references look like:

screenshot 1

screenshot 2

Any suggestions on how I can convert these imported Subversion remote branches and tags into local Git branches and tag would be greatly appreciated!


Solution

  • Git uses two locations for storing refs (i.e. branches, tags, ...): First it stores each ref as an individual file below .git/refs. After a while and/or if to many refs have accumulated git pack-refs packs the current state into one file .git/packed-refs. git pack-refs is called by git gc which in turn is executed automatically by some git commands.

    So it is not a bug that .git/refs does not contain your branches. The definitive command to get all refs is git for-each-ref.

    git svn does store additional data in git/svn but not the refs per se.

    If the post-processing did not work I assume that the patterns for the refs did not match. So compare the output of git for-each-ref with the strings in the commands: refs/remotes/tags and refs/remotes.