git svn migration failing with svn 1.8

2019-03-15 05:29发布

问题:

I'm following the steps in: http://git-scm.com/book/en/v2/Git-and-Other-Systems-Git-as-a-Client

to move an svn repository to git. My local svn version is:

$ svn --version svn, version 1.8.10 (r1615264) compiled Aug 25 2014, 10:52:18 on x86_64-apple-darwin12.5.0

git version:

$ git --version git version 2.1.0

When I clone the repository I get an error reading the local file system format:

$ git svn clone file:///tmp/test-svn -s
Initialized empty Git repository in /private/tmp/test-svn/.git/
Couldn't open a repository: Unable to connect to a repository at URL 'file:///tmp/test-svn': Unable to open an ra_local session to URL: Unable to open repository 'file:///tmp/test-svn': Expected FS format between '1' and '4'; found format '6' at /usr/local/Cellar/git/2.1.0/lib/perl5/site_perl/Git/SVN.pm line 310

According to this svn release note FS format 6 was introduced in svn 1.8: http://subversion.apache.org/docs/release-notes/1.8.html#revprop-packing

Could it be the git 2.1 Perl script isn't yet compatible with this svn release? More importantly how can I get this svn repository converted to git?

回答1:

I got an answer on the git-users email list.

The solution is to run a local svnserver and use the svn protocol when running git svn clone instead of the file protocol. That avoids git-svn needing to parse the svn 1.8 file format.

Suppose your repository is in a directory /path/to/repository/test-svn. Change into the /tmp directory and run

svnserve -d -r /path/to/repository

Then you can run

git svn clone svn://127.0.0.1/test-svn -s

Afterwards, stop the svnserver and delete the temporary svn repository.