1

I want to launch a git clone command with my password and username but my password contains special characters (e.g.: pass/word@123 ) :

git clone https://username:pass/word@123@mysite.com/myrepo

The command is obviously not working because it does wrongly interpret the special characters. I tried using percent encoding and backslash but it is still not working. Git says the authentication failed when I use password%40123 instead of password@123. What can I do ?

Note : I am not using github, but Microsoft TFS.

Note 2 : I can not type the url first and the password after when git asks (because I try to run the command from PHP/Symfony (but percent encoding is still not working when using it directly from command line))

Note 3 : Of course I cannot change the password

Thanks.

EDIT :

After testing, it is working on a GitHub repo (with percent encoding) but not on TFS. So the problem is coming from TFS.

Community
  • 1
  • 1
Damien
  • 11
  • 1
  • 3

1 Answers1

3

Just as you have said, it will treat characters after @ as the remote site url.

Take a look at this thread: How to provide username and password when run "git clone git@remote.git"?

It is more popular to use an ssh key instead of a password when automating a git clone from a guest OS.

If you want to use password with special character, like an exclamation mark, you need to use percent encoding which is often called URL encoding.

!   #   $    &   '   (   )   *   +   ,   /   :   ;   =   ?   @   [   ]
%21 %23 %24 %26 %27 %28 %29 %2A %2B %2C %2F %3A %3B %3D %3F %40 %5B %5D

More details please refer similar question here: Escape @ character in git proxy password

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • As I said before, ssh keys are not working because of our repository policies (and this cannot be changed). And it is not working to use percent-encoding to clone a TFS repository (authentication failed). – Damien Jul 18 '18 at 07:11
  • @Damien If so, I'm afraid you may have to change the password format, which should do the trick. – PatrickLu-MSFT Jul 24 '18 at 01:54
  • No, unfortunately, I am still stuck. – Damien Aug 01 '18 at 07:09