记Git保存本地密码与删除本地缓存

参考:

https://www.jianshu.com/p/77b0340a02f3

https://blog.csdn.net/yunlong782/article/details/50887833?locationNum=7&fps=1


保存密码

 git 有三种策略查找用户名密码:去缓存中找,去磁盘中找,去钥匙串中找。

 ~/User/用户名/.gitconfig  中配置了Git查找密码的策略。cache/store/osxkeychain 分别对应上方三个策略

配置 Git 使用磁盘策略(可选参数 cache/store/osxkeychain

 Window 系统下添加环境变量 %HOME% 指向任意目录,将会在指定目录下创建相关文件

 .gitconfig 文件中保存 Git 使用策略,.git-credentials 文件保存对应 URL 使用的帐号密码

 git  config --global  credential.helper  store 

 配置帐号密码

 $ git config --global user.name "xxxxxx"
 $ git config --global user.email "xxxx@.com"

删除本地缓存

 //查找系统支持的策略方式

 git help -a | grep credential 

 // credential.helper 字段中配置的即为 Git 查找策略
 //查找 Git 的全局配置

 git config --list 



 //查看目前 Git 使用的策略
 git config credential.helper

 //查看目前 Git 使用的策略所在目录,找到后可以直接删除
 git config --show-origin --get credential.helper 

 删除后参照保存本地密码可以再次设置 Git 查找策略与帐号密码

原文地址:https://www.cnblogs.com/Z-onee/p/9361817.html