Damien
Damien

Reputation: 21

TFS Git command line with special characters

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@[email protected]/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.

Upvotes: 2

Views: 3197

Answers (1)

PatrickLu-MSFT
PatrickLu-MSFT

Reputation: 51103

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 [email protected]"?

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

Upvotes: 4

Related Questions