git 使用用户名密码 clone 的方式:
- git clone http://username:password@remote
例如:我的用户名是 abc@qq.com, 密码是 abc123456,git 地址为 git@xxx.com/www.git
- git clone http://abc@qq.com:abc123456@git.xxx.com/www.git
执行报错:
fatal: unable to access 'http://abc@qq.com:abc123456@git.xxx.com/www.git/':
Couldn't resolve host'qq.com:abc123456@git.xxx.com'
报错原因是因为用户名包含了 @符号,所以需求要把 @转码一下
$userame='abc@qq.com';
echo urlencode($userame);
?>
abc@qq.com
@符号转码后变成了 @,所以只需在 clone 时将 username 变为 abc@qq.com 即可,再次执行就 ok 了。
为了防止密码中也可能会有 @,我觉得在拼接之前,可以对用户名和密码分别进行编码操作。
来源: http://www.cnblogs.com/pqchao/p/6483143.html