參考:git
https://www.jianshu.com/p/77b0340a02f3緩存
https://blog.csdn.net/yunlong782/article/details/50887833?locationNum=7&fps=1spa
保存密碼.net
git 有三種策略查找用戶名密碼:去緩存中找,去磁盤中找,去鑰匙串中找。code
~/User/用戶名/.gitconfig 中配置了Git查找密碼的策略。cache/store/osxkeychain 分別對應上方三個策略blog
配置 Git 使用磁盤策略(可選參數 cache/store/osxkeychain)get
Window 系統下添加環境變量 %HOME% 指向任意目錄,將會在指定目錄下建立相關文件it
.gitconfig 文件中保存 Git 使用策略,.git-credentials 文件保存對應 URL 使用的賬號密碼io
git config --global credential.helper store
配置賬號密碼class
$ 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 查找策略與賬號密碼