git使用用戶名密碼clone的方式:
1
|
git clone http:
//username
:password@remote
|
例如:我的用戶名是abc@qq.com,密碼是abc123456,git地址為git@xxx.com/www.git
1
|
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'
報錯原因是因為用戶名包含了@符號,所以需求要把@轉碼一下
<?php
$userame='abc@qq.com';
echo urlencode($userame);
?>
abc%40qq.com
@符號轉碼后變成了%40,所以只需在clone時將username變為abc%40qq.com即可,再次執行就ok了。
為了防止密碼中也可能會有@,我覺得在拼接之前,可以對用戶名和密碼分別進行編碼操作。