git clone 指定用户名密码

发布时间 2023-04-19 11:16:59作者: jack_Meng

这种方法是因为本地git已经登录了一个git账号,但是没有权限,所以会用账号拉取。

命令:git clone http://邮箱(或用户名):密码@仓库

格式:git clone http://username:password@remote

示例:

git clone http://15000000000:123456@git.xxx.com/abc/projectName.git
//示例中是假地址

有另外一种方法:

打开本地电脑的用户账号》凭证管理》git:https://xxxxxx 这个是登录过的账号,只需要删除掉,然后git clone https://xxxx,之后会弹出登录框就可以了,这个方法会重新登录本地的git账号。

 

出处:https://blog.csdn.net/rta_bh/article/details/110493545

=========================================================================================

git clone使用用户名和密码报错

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'

 报错原因是因为用户名包含了@符号,所以需求要把@转码一下

<?php
$userame='abc@qq.com';
echo urlencode($userame);
?>
abc%40qq.com

把@符号转码后变成了%40,所以只需在clone时将username变为abc%40qq.com即可,再次执行就ok了。

为了防止密码中也可能会有@,我觉得在拼接之前,可以对用户名和密码分别进行编码操作。

 

出处:https://www.cnblogs.com/pqchao/p/6483143.html

=======================================================================================

git clone 用户名或密码包含@的错误

git使用用户名密码clone的方式:

git clone http://username:password@remote

eg: username:  abc@qq.com, pwd: test, git地址为git@xxx.com/test.git

git clone http://abc%40qq.com:test@git@xxx.com/test.git

注意:用户名或密码中包含@符号,一定要转义 @符号转码后变成了%40

 

出处:https://www.cnblogs.com/tonyauto/p/10722563.html