I am trying to import my repository from svn to git using svn2git, but it seems like it\'s failing when it hits a branch. What\'s the problem?
Found possible
I was following some svn to git instructions when I ran into the same error message. The error occurred when I ran this command:
git svn clone file:///pathto/repo /pathto/new-git-repo –-no-metadata -A authors.txt -t tags -b branches -T trunk
After the error occurred, I edited the .git/config-file as follows:
tags = tags/*:refs/remotes/svn/tags/*
branches = branches/*:refs/remotes/svn/*
->
tags = tags/*:refs/remotes/svn/tags/*
branches = branches/*:refs/remotes/svn/branches/*
I.e., I just formatted the "braches" line to be similar to the "tags" line. Then I ran the command again. The process produced a valid git repo with remote branches.
To fix your problems you have to convert the imported remote branches and tags to local ones.
Section from Scott Chacone (PRO GIT): Original link: http://progit.org/book/ch8-2.html:
To move the tags to be proper Git tags, run
$ cp -Rf .git/refs/remotes/tags/* .git/refs/tags/
$ rm -Rf .git/refs/remotes/tags
This takes the references that were remote branches that started with tag/ and makes them real (lightweight) tags.
Next, move the rest of the references under refs/remotes to be local branches:
$ cp -Rf .git/refs/remotes/* .git/refs/heads/
$ rm -Rf .git/refs/remotes
This worked for me perfectly.
It seems svn2git doesn't pass the branch configuration correctly. I had the standard layout but the error occurred. I fixed it with passing the defaults for the layout again:
$ svn2git http://repos --branches branches --tags tags --trunk trunk
Then it worked as expected.
Your subversion repository does not have a standard trunk/branches/tags structure. Specify the alternate places for where you branched by using the --branch, --tag, --trunk options.
I had to open up the .git/config file and delete all the branches and tags entries under the svn-remote section and run the 'git svn clone' command for this error to go away. Apparently, if I run this command multiple times (usually stop and re-start from a revision), the branch/tag entries get added to the config file instead of being reused, which causes the error.