46

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?

0

2 Answers 2

69

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

git svn clone also works on remote svn repos

# for example
git svn clone https://your.hostname/path/here/svn/
  • note: git svn clone gets all commits, as opposed to svn checkout only getting the most recent file set, and so the shell command can take a long time if the svn repo has lots of commits and/or files.
12
  • 15
    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
    – kurast
    Commented Feb 20, 2017 at 13:49
  • Thanks @kurast, i'll make the answer more obvious to remove it.
    – zionyx
    Commented Feb 20, 2017 at 20:35
  • 5
    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.
    – flohack
    Commented Jun 4, 2018 at 19:19
  • 5
    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.
    – flohack
    Commented Jun 6, 2018 at 17:58
  • 1
    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
    – Azghanvi
    Commented May 12, 2021 at 2:58
9

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.

4
  • 2
    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" Commented Mar 13, 2013 at 22:06
  • 3
    file:// URLs work for me. No idea about the drive specifier portion, I don't use windows.
    – qqx
    Commented Mar 13, 2013 at 22:44
  • 2
    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 Commented Mar 14, 2013 at 14:53
  • 10
    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
    – Crayon
    Commented Dec 19, 2015 at 15:38

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