Clone a repo with Slash in Password

前提是你 提交于 2019-12-08 03:55:07

问题


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:


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.



来源:https://stackoverflow.com/questions/24718519/clone-a-repo-with-slash-in-password

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!