记录一下使用 git 过程中常见的一些问题和解决方案

一、问题:git配置的邮箱更改密码后,无法git pull代码,显示fatal:Authentication failed for 'xxx',截图如下所示

git 常见失败问题的记录(Windows)_git

解决办法:

1、找到.gitconfig文件,一般是在C:\Users\Administrator这个目录下面

git 常见失败问题的记录(Windows)_解决方案_02

2、打开这个文件,删除[credential]  helper = store这两行数据,然后保存

git 常见失败问题的记录(Windows)_数据_03

3、重新执行git pull,但是这个时候你会发现需要重新输入用户名和密码了,但是这里又有一个问题,就是需要你每次都输入用户名和密码,解决办法如下

git config --global credential.helper store

然后再执行一次git pull,这个时候需要输入用户名和密码,输完这一次之后就不用再输入了

二、问题:git pull 代码后出现下面的错误

error: some local refs could not be updated; try running
'git remote prune xxxxxx' to remove any old, conflicting branches

解决办法:

git gc --prune=now
git remote prune origin