Clone a repo with Slash in Password

2020-03-30 08:50发布

Cloning a repo can be done with

git clone https://username:password@github.com/username/repository.git

However, when the password contains a forward slash, this doesn't work. Error is:

error: Couldn't resolve host 'klaus777:password' while accessing 
https://klaus777:password/.@bitbucket.org/romeo/server-code.git/info/refs

fatal: HTTP request failed

If I URL Encode the Slash, I get the following error:

error: The requested URL returned error: 401 while accessing 
https://klaus777:password%2F%2E@bitbucket.org/romeo/server-code.git/info/refs

fatal: HTTP request failed

Hence, the question: How do you deal with forward slash in password?

PS. If I remove password from URL and provide it when prompted, everything works just fine.

1条回答
放荡不羁爱自由
2楼-- · 2020-03-30 09:30

A percent encoding for forward slash should be %2F alone, check if you need to encode the '.' (%2E) that you seem to also have in your password.

https://klaus777:password%2F.@bitbucket.org/romeo/server-code.git

That doesn't seem to work for GitHub though: the OP Klaus confirms in the comments:

I changed the password.

查看更多
登录 后发表回答