菜鸟笔记
提升您的技术认知

解决git操作一直要求输入用户名和密码

问题描述

一直使用的git版本比较旧,还是5年前的。新电脑安装了新的git 2.37版本。然后每次pull, push都要求输入用户名和密码。这个有些麻烦了。

解决

解决方法是:保存一下用户本地凭证,这样每次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时,输入了用户名和密码后,就保存下来了,以后就不会再要求输入了。