git - how can I clone local svn repository?

48,003

Solution 1

You should be able to succeed like this:

git svn clone file:///e/svn_repo_on_E_drive

Similar to svn checkout command:

svn co file:///e/svn_repo_on_E_drive

file:// for folder on the current drive of the executing CMD prompt, file:///d/some_folder for D:\some_folder.

Note: The extra / and the removed colon : in the file link on Windows. file://e:/svn_repo_on_E_drivefile:///e/svn_repo_on_E_drive

Solution 2

For a local repository you use a file:// URL, same as would be used for doing a checkout with the normal svn client.

If you're trying to copy the entire history, and using git svn clone --stdlayout just use the URL that you would use to checkout the trunk with svn minus the /trunk portion at the end.

Share:
48,003
Bulwersator
Author by

Bulwersator

Updated on June 09, 2021

Comments

  • Bulwersator
    Bulwersator almost 3 years

    I am completely unable to find any explanation how I should specify location of existing svn repository.

    In other words - what should be used as URL in

    git svn clone URL
    

    when svn repository is local?

  • Bulwersator
    Bulwersator about 11 years
    So file:///X:/path/to/repos should work? Weird, as it fails with "Couldn't open a repository: Unable to open an ra_local session to URL: Unable to open repository"
  • qqx
    qqx about 11 years
    file:// URLs work for me. No idea about the drive specifier portion, I don't use windows.
  • Francesco Frassinelli
    Francesco Frassinelli about 11 years
    From your last comment I suppose you're using Windows. Try to remove the third "/". Maybe it doesn't work because there's a bug: code.google.com/p/tortoisegit/issues/detail?id=1402
  • Crayon
    Crayon over 8 years
    You need to remove the colon ( : ) from the drive letter. So instead of file:///X:/path/to/repos you need to use file:///X/path/to/repos
  • kurast
    kurast about 7 years
    I was having a problem with this approach until I removed the colon (:) from drive on the file URL. Usually, in windows you see this file:///e:/svn_repo_on_E_drive , but for git you need to remove the ':' from the drive, leaving file:///e/svn_repo_on_E_drive
  • zionyx
    zionyx about 7 years
    Thanks @kurast, i'll make the answer more obvious to remove it.
  • flohack
    flohack almost 6 years
    For me it does not work in any combination of /// and other things: Can't create session: Unable to connect to a repository at URL 'file://d/temp/xxxx': Local URL 'file://d/temp/xxxx' contains unsupported hostname at / mingw64/share/perl5/site_perl/Git/SVN.pm line 144.
  • zionyx
    zionyx almost 6 years
    @flohack, based on the syntax, i assume you are using the command on Windows? Have you tried file:///d/temp/xxxx? What's the full command used when you get the error?
  • flohack
    flohack almost 6 years
    With 3 /// I get slightly different result: $ git svn clone file:///d/temp/xxxx/ Initialized empty Git repository in D:/yyyy.lt/git/xxxx/.git/ Can't create session: Unable to connect to a repository at URL 'file:///d/temp/xxxx': Unable to open repository 'file:///d/temp/xxxx' at /mingw64/share/perl5/site_perl/Git/SVN.pm line 144.
  • zionyx
    zionyx almost 6 years
    Unfortunately no. I am able to reproduce the same error you guys get. Which means, the behavior of Git has changed over time? Hmm.
  • flohack
    flohack almost 6 years
    I finally installed svn+ssh server only to do this import :)
  • zionyx
    zionyx almost 6 years
    Yes, of course, you can use svnserve to serve so you can use svn:// over file:///. A great workaround!
  • zionyx
    zionyx almost 6 years
    Try to create a symbolic link of the repository in a different drive to the new location, then you do not need to mess with drive letters in your file:///.
  • Azghanvi
    Azghanvi almost 3 years
    Your reply saved my old repo which i was going to dump. Unable to find anywhere else: file://e:/svn_repo_on_E_drive → file:///e/svn_repo_on_E_drive
  • bitmountain
    bitmountain over 2 years
    Can not make it work. Got this error: Unable to open repository 'file:///d/projects/xxx' at C:/Program Files/Git/mingw64/share/perl5/Git/SVN.pm line 310. I am using the git version of version 2.34.0.windows.1.