家里的电脑安装了新的git 2.37版本。然后每次pull, push都要求输入用户名和密码。而公司的电脑就没有这个问题,每次输入用户名和密码也挺麻烦的,那如何解决呢。

git一直要求输入用户名和密码解决方法

解决方法是:保存一下用户本地凭证,这样每次git操作时,使用保存的凭证就好了。

命令

## 全局的
git config --global credential.helper store

git config --global user.email "email"
git confgi --global user.name "name"

在多个项目,不同的git服务器,不同用户名时,对每个项目设置各自的local 配置。

## local
git config --local credential.helper store

git config --local user.email "email"
git confgi --local user.name "name"

然后,再次pull,push时,输入了用户名和密码后,就保存下来了,以后就不会再要求输入了。