git clone 指定用户名和密码

git clone https://username:password@remote-git-repository-url
# 例如
git clone https://roc:123456@e.coding.net/roc/example.git
如果用户名使用的是邮箱,那么 @ 符号需要转义成 %40,否则会无法识别邮箱,与 Git 仓库地址前面的 @ 造成冲突:

# 例如
git clone https://roc@qq.com:123456@e.coding.net/roc/example.git
# 需要写成
git clone https://roc%40qq.com:123456@e.coding.net/roc/example.git
【注】转义仅仅是在命令行或者是代码中需要,如果使用的是工具的话可以不用转义,工具会帮我们进行转义。

原文链接: git clone 指定用户名和密码 版权所有,转载时请注明出处,违者必究。
注明出处格式:流沙团 ( https://gyarmy.com/post-798.html )

发表评论

0则评论给“git clone 指定用户名和密码”