使用密码@的Git克隆

Gus*_*ras 8 git shell command-line escaping github

我需要逃避使用密码的@,因为它与主机混淆.

例1: git clone https://user:p@ssword@github.com/user/repo.git

当我运行上面的例子时,这是错误的,因为密码有@他知道下一个参数是主机.试图用\逃脱,或者你可以使用""之间的网址,但事实并非如此.

例2: (echo user; echo p@ssword) | git clone https://github.com/usuario/repo.git

当我只使用命令时,git clone https://github.com/usuario/repo.git他询问用户和密码,所以我使用了上面的命令,这与我用来更改一行上的root密码的命令相同.

小智 8

我认为你正在寻找的是逃避特殊字符@,你可以使用编码%40而不是@.此链接可能有助于在git代理密码中使用Escape @ character


Sar*_*dra 5

您可以将@替换为其URL编码格式%40

如果您的密码是password@99。修改密码为%4099

git clone https://username:password%4099@bitbucket.org/sarat.git
Run Code Online (Sandbox Code Playgroud)