> 技术文档 > ubuntu repo拉取代码时报错git requires authentication_git requires authentication, but repo cannot perfo

ubuntu repo拉取代码时报错git requires authentication_git requires authentication, but repo cannot perfo

在这里插入图片描述
在ubuntu20.04上用repo拉取代码时,git报错:
git requires authentication, but repo cannot perform interactive authentication. Check git credentials.

git无法重新进行信息认证,正常在用http/https拉取代码的时候,会提示输入用户名密码,但是这种情况下,没有输入的机会
使用HTTP/HTTPS协议clone代码时,不需要配置SSH key
所以并不ssh key的问题

解决方法

1. 直接手动将认证信息添加进文件

vim ~/.git-credentials 

2. 执行命令,保存认证信息

git config --global credential.helper store

此命令也可以帮助git clone的时候不需要反复输入密码

3. 查看执行情况

cat ~/.gitconfig

会有如下内容:

[credential]helper = store

说明操作成功,再去执行拉取代码的命令试试,就能成功拉取代码了。
具体为什么不会提示输入用户名密码的原因,尚不清晰,有待继续调查

Windows端解决办法请参考大佬的文章:
https://blog.csdn.net/hacker_lpy/article/details/124078021