31

I want to clone a svn repository using git, with a username and password given on the command-line.

I can write:

svn checkout --username user --password pass svn://server/repo

But I can't use --password with git svn clone:

git svn clone --username user --password pass svn://server/repo
Unknown option: password

How can I give the password to git svn clone on the command-line?

Alternatively, is there a kind of --svn-options switch to git-svn?

P.-S. Note that I need to specify it on the command-line, because there are multiple repos on this server with different user/pass, and svn stupidly assumes that all repos use the same username/password, so half of the time I get svn: Authorization failed, without it asking for the password, even if I use --username (it seems to ask for the password sometimes, but it's not robust enough to be used in a script).

Suzanne Soy
  • 3,027
  • 6
  • 38
  • 56

2 Answers2

22

git svn uses SVN commands directly and thus the internally saved password of SVN.

Run the command:

svn checkout --username user --password pass svn://server/repo

and let SVN remember your password.

If this does not work remove the saved SVN authentications:

$HOME/.subversion/auth/svn.simple/*

Then git svn clone will prompt you for the password.

m13r
  • 2,458
  • 2
  • 29
  • 39
jolestar
  • 1,285
  • 15
  • 21
  • 1
    Just a note. svn checkout can be quite time consuming. There is no need to wait for it to complete though. Once the checkout starts, the password is saved and you can cancel the checkout process (Ctrl+C is windows). – Josef Sábl Aug 24 '15 at 13:04
  • 2
    try `--depth empty` as in `svn checkout --username someuser --password somepass --depth empty ` – Mike D Dec 02 '16 at 17:52
  • 2
    If you're just running it to get the password reset, you can just do `svn log` instead of `svn checkout`. That will probably complete so quickly that it won't be worth your time to try to ctrl+c it. – LinuxDisciple Jul 17 '20 at 19:39
16

Just specify the username with --username and you should be prompted for a password.

See git svn --help or man git svn for further information.

m13r
  • 2,458
  • 2
  • 29
  • 39
JohnK
  • 406
  • 4
  • 6
  • 5
    As noted in my question, I needed to give the password on the command-line, not be prompted for it (unless I can safely pipe an "echo" into that or something similar). – Suzanne Soy Nov 12 '14 at 10:15