最近的项目在执行 git pull/push 的时候,老是提示要输入账号和密码。输入正确之后,下次执行 git pull/push 的时候还需要重新输入账号密码。

这应该是我不知道啥时候使用了错误的账号和密码,解决方法很简单:先 cd 到根目录,执行以下命令:

git config --global credential.helper store

然后 cd 到项目目录,执行 git pull 命令,会提示输入账号密码。

输完这一次以后就不再需要

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

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

git config --local user.email "email"
git confgi --local user.name "name"
git配置级别

# 全局,保存在~/.gitconfig(windows),/etc/gitconfig(linux)
git config --global 配置内容
# 本地,保存在本地库/.git/config
git config --local 配置内容
 

查看GIT设置
# 查看所有git设置
git config -l

# 查看git存储方式
git config -l | find "credential"
credential.helper=store

# 查看不同级别的credential.helper
# 全局
D:\test> git config --global credential.helper
manager
# 本地
D:\test> git config --local credential.helper
store
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐