2

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!

jmastic
  • 109
  • 1
  • 10
  • possible duplicate of [git-svn clone | spurious branches](http://stackoverflow.com/questions/11356901/git-svn-clone-spurious-branches) – sleske Jul 28 '13 at 17:38

1 Answers1

2

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.

Dmitry Pavlenko
  • 8,530
  • 3
  • 30
  • 38
  • And about master and trunk: what cleaning did you perform? Usuall git-svn creates refs/heads/master pointing to refs/remotes/trunk and refs/remotes/* for branches. With Git you should have all branches in refs/heads/*. If trunk and branches point to the same commit, and you have no branches/master in SVN, better get rid of refs/heads/trunk. – Dmitry Pavlenko May 19 '12 at 01:10
  • Thanks for the information, Dmitry. This is for commercial use, and we are looking to completely switch from SVN to Git, so I don't think either of those projects are exactly what we're looking for. The cleaning I did was: 1. git reset --hard 2. cp -Rf .git/refs/remotes/* .git/refs/heads/ 3. rm -Rf .git/refs/remotes I'll admit I'm not entirely sure what you're talking about regarding the trunk and branches. The original SVN repo didn't have the standard structure, everything was in the root, if that helps at all. – jmastic May 19 '12 at 05:11
  • You may run "git rev-parse refs/heads/master" and "git rev-parse refs/heads/trunk". If the output is the same you may delete "refs/heads/trunk" reference, use refs/heads/master instead. But note: "cp -Rf .git/refs/remotes/* .git/refs/heads/" is not enough; some references may be packed. So make sure you have no .git/packed-refs file, or you may lose some branches. – Dmitry Pavlenko May 19 '12 at 11:01
  • Thanks again, Dmitry. I think I am going to go with SmartGit after all. It seems to be doing what I need, and it is definitely worth not having to manually do this. I am curious, though, if I can make some of my directories into branches. I'm having some difficulty doing that. Everything is being imported to the root and I'm losing the branches I mentioned earlier. They are listed as directories in the master branch, though. Do you know if this is possible? – jmastic May 20 '12 at 05:23
  • No, SmartGit will ignore them if you'll clone the repository as trunk/branches/tags layout. – Dmitry Pavlenko May 20 '12 at 20:17