Search code examples
gitversion-controlgit-svnsvn2git

Space in branch name causing SVN to GIT migration issues


I'm trying to migrate an old SVN repository over to GIT using svn2git (on my Windows box) using the following command:

svn2git https://my/svn/url --verbose --authors authors.txt

and things were running okay until I hit the following error:

fatal: Not a valid object name refs/remotes/svn/VS2010 Port
cat-file commit refs/remotes/svn/VS2010 Port: command returned error: 128

It seems that someone (ages back) created a branch with a space in the name and this is causing havoc on the process. Running git branch -a shows the branch in question:

remotes/svn/VS2010%20Port

I did some searching around Google and StackOverflow and came across a few posts including this one (although it is referring to tags).

First I attempted the suggestion of removing the branch with git branch -r -d svn/VS2010%20Port (retaining this branch is not important) and then I reran my svn2git command. It begins running and eventually fails with the same error. I also tried removing the branch and adding the flag --exclude '.*VS2010.*' to my svn2git command but this didn't help:

svn2git https://my/svn/url --verbose --authors authors.txt --exclude '.*VS2010.*'

Next, I tried the other suggestion of running the mv command to move the file/directory with the %20 in the name to one with an actual space:

mv VS2010%20Port VS2010\ Port

Since my issue isn't with tags I wasn't 100% where to run this but I tried in the following locations:

  • .git\svn\refs\remotes\svn
  • .git\refs\remotes\svn
  • .git\logs\refs\remotes\svn

When I ran the svn2git command afterwards I eventually got the same issue.

Finally I found this post which is specifically about branches but the solution was to edit the packed-refs file and replace %20 with spaces. Although I didn't see the VS2010%20Port branch listed here so I could not go through with this solution.

Does anyone have any suggestions on something I could try or something I may have missed?

Update: I was able to get some progress happen by adding the --ignore-refs flag with a regex that would match the VS2010 Port string. Its a large repository so it took a very long time but eventually it seemed to finish. Unfortunately, I saw no files in the directory (just the .git directory) so I'm assuming something went wrong. I decided to take a step back and try again fresh with the git svn clone command and this time I provided the --ignore-refs and --ignore-paths flags from the start. Hopefully I'll get better results this time.


Solution

  • Just to put an end to this question, I was able to get this process working thanks to the various comments and suggestions. In the end I moved away from svn2git and I was able to get my repository migrated (to a point that I'm satisfied with) using git svn clone along with the --ignore-refs option. I'm not exactly clear why svn2git or git svn init followed by git svn fetch did not work but in the end I got.