31

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 branch point: https://s.aaa.com/repo/trunk/project => https://s.aaa.com/repo/branches/project-beta1.0, 128
Use of uninitialized value in substitution (s///) at /opt/local/libexec/git-core/git-svn line 1728.
Use of uninitialized value in concatenation (.) or string at /opt/local/libexec/git-core/git-svn line 1728.
refs/remotes/trunk: 'https://s.aaa.com/repo' not found in ''

Running command: git branch -l --no-color
* master
Running command: git branch -r --no-color
  trunk
Running command: git checkout trunk
Note: checking out 'trunk'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at f4e6268... Changing svn repository in cap files
Running command: git branch -D master
Deleted branch master (was f4e6268).
Running command: git checkout -f -b master
Switched to a new branch 'master'
Running command: git gc
Counting objects: 450, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (368/368), done.
Writing objects: 100% (450/450), done.
Total 450 (delta 63), reused 450 (delta 63)
2

5 Answers 5

63

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.

6
  • 2
    Thanks, I deleted everything under the [svn-remote "svn"] section. This worked for me..
    – kpasgma
    Jun 30, 2011 at 20:04
  • 10
    I didn't need to delete everything, just duplicate lines of: branches = branches/*:refs/remotes/svn/* and tags = tags/*:refs/remotes/svn/tags/* (keeping one) Nov 28, 2012 at 4:22
  • 1
    @BrettPorter I had duplicate of the tags... and needed to remove all of them (apparently command was always adding one)
    – Eric MSFT
    Sep 25, 2014 at 16:49
  • Just deleted all of tags and branches in my config file and it works..Like Eric MSFT
    – StefMa
    Nov 3, 2014 at 13:52
  • In my case this was caused by re-running svn2git, after the original failed because of an unknown author ( which I fixed). Deleting the entire directory and running from a clean directory worked fine.
    – WallStProg
    Oct 7, 2016 at 20:23
6

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.

2
  • Is that a question? An answer? Or just 'for our information'?
    – Manuel
    Jul 24, 2013 at 7:30
  • It's one way to get pass the error (which in my case crashed the process) and get the cloning from svn to git done.
    – jaolho
    Jul 24, 2013 at 11:30
5

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.

2
  • Worked for me as well... !!!! But in my case, I only had to do the change for "remotes" as the tags did not even existed when it failed. Dec 16, 2013 at 5:25
  • After it broke again, I just deleted all the entries from the "remote svn" block in the .git/config file and it worked! Dec 16, 2013 at 5:42
4

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.

0
2

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 Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.