命令行 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

【注】转义仅仅是在命令行或者是代码中需要,如果使用的是工具的话可以不用转义,工具会帮我们进行转义。

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注