34

I'd like to use SVN and Git together. I have an svn repository, and I'm trying to fetch to a working directory, but I encounter an error as below.

svn, version 1.6.6 (r40053)

git version 1.7.3.1.msysgit.0

The svn repository path is file:///d:/tmp/test-svn/repos

These are the steps I did:

D:\tmp\test-svn>mkdir my-project

D:\tmp\test-svn>cd my-project

D:\tmp\test-svn\my-project>git svn init file:///d:/tmp/test-svn/repos

Initialized empty Git repository in D:/tmp/test-svn/my-project/.git/

D:\tmp\test-svn\my-project>git svn fetch

Couldn't open a repository: Unable to open an ra_local session to URL: Unable to
 open repository 'file:///d:/tmp/test-svn/repos/my-project/trunk': Expected FS f
ormat '2'; found format '4' at C:\Program Files\Git/libexec/git-core/git-svn lin
e 1773

So what is the issue? How can I fetch data from svn repository to the git working directory?

Thank you.

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
Sambath Prum
  • 1,858
  • 9
  • 25
  • 33

2 Answers2

46

I think this is the following issue: http://code.google.com/p/msysgit/issues/detail?id=298

Possible solution is to setup svnserve and use the svn:// protocol instead of file:///

See here for setting up svnserve on Windows: http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-serversetup-svnserve.html

UPDATE

svnserve is available as a part of TortoiseSVN if you use Windows OS (I checked with TortoiseSVN version 1.8.6)

Then you just start:

svnserve -d -R --root c:\path\to\svn\repo

and clone the repository with following command:

git svn clone svn://localhost/path/inside/svn/repo
sergtk
  • 10,714
  • 15
  • 75
  • 130
tekumara
  • 8,357
  • 10
  • 57
  • 69
  • 10
    This is the best solution: TortoiseSVN comes with the necessary command line tools already (They are not installed by default though, you have to select them in the installer). Then you just start `svnserve -d -R --root d:\svnroot` and clone the repository with `git clone svn://localhost/myproject`. – Maddin Jan 29 '13 at 08:59
1

I can propose to clone your repository with SmartGit. It have git-svn functionality implemented in java, which is significantly faster than git-svn and outperforms it. Hope it will work for you.

But if you have an access to your SVN repository server I recommend you to install SubGit into it. In this case you will get a Git repository that is automatically synchronized with SVN repository (and concurrent-safe).

Both approaches has large advantages over git-svn like: automatical tags, ignores, EOLs translation. SubGit also tries to preserve dates as it is possible while committing to SVN.

Dmitry Pavlenko
  • 8,530
  • 3
  • 30
  • 38
  • Thanks for SmartGit, it works perfectly. MsysGit keeps failing with AV when cloning an SVN repo and SmartGit just works. Moreover it clones the whole repo much more quicker than git-svn does. – Fr0sT Aug 29 '14 at 12:38