Search code examples
gitsvnclonegit-svn

Subversion to Git: Clone creating branches?


I am converting a large (>6500 commits) Subversion repository to a Git repo and have been running into some problems I am hoping someone can help with. Here is where I'm at:

I created a local Subversion repository backup of the remote repository. I am converting that repository to Git using this:

git svn clone svn://localhost/svn gitrepo –no-metadata -A authors-transform.txt -t tags -b branches -T trunk

This does create a Git repo, but when it does, it is creating some additional branches with what looks like commit numbers. I definitely don't intend for those to be there. After cleaning up a little bit from the clone, my ".git/refs/heads/" folder looks like this:

branch1
branch1@6701
branch1@6736
branch2
branch3
branch4
master
trunk

Is there any reason why git svn clone would be doing this? Is there something in those commits that might be creating an entirely new branch?

Also, before I push this newly created Git repo to GitHub, should I have both a master and a trunk branch? I'm not sure what Git / GitHub is going to look for exactly. Thank you!


Solution

  • If I remember correctly, refs/remotes/XXX@rev branch is created for deleted branch. Suppose they are not created. Then refs/remotes/XXX branch does not exist to (because it was deleted in SVN). Then Git commits corresponding deleted SVN branch are not reachable from any Git branch, so can be collected as garbage. If you see both refs/remotes/XXX and refs/remotes/XXX@rev existing, this might mean that the branch was replaced. But unfortunately, as I know, git-svn creates merge commits for branch replacements, that is absolutely wrong from history translation point of view.

    Instead, for SVN->Git migration have a look at 2 another projects. The first one is SubGit that is recommended if you have an access to your SVN server. It processes replacements as replacements, merges as merges; but also translates ignores, svn:eol-style properties (to corresponding .gitattributes values), tags and so on.

    Another alternative is SmartGit if you don't have access to your SVN server. It also provides reasonable translation (merges to merges, ignores to ignores), but also can translate svn:externals in to .gitsvnextmodules file that shows as modules.