問(wèn)題
今天在提交git項(xiàng)目時(shí)遇到提示:fatal: unable to get credential storage lock: File exists。
但是似乎提交依然成功了,不知道這個(gè)報(bào)錯(cuò)有什么影響。
原因
git的config中credential.helper項(xiàng)有重復(fù),我的是同時(shí)含有credential.helper=store
和credential.helper=manager
解決辦法
在git的config中找到credential.helper項(xiàng),刪除其中一項(xiàng)。
- 首先要確定是否是有config中credential.helper重復(fù)引起的問(wèn)題,執(zhí)行
git config -l
可查看所有參數(shù) - 確定參數(shù)配置的位置。分別執(zhí)行
git config --local -l
git config --global -l
-
git config --system -l
可查看當(dāng)前項(xiàng)目、全局、系統(tǒng)的參數(shù),找到credential.helper=manager
的那一項(xiàng)
- 如果是在系統(tǒng)參數(shù)中,則執(zhí)行
git config --system --unset credential.helper
即可刪除system中的此參數(shù)配置。如果是在local或global則將其中的system替換即可。 - 如果依然有問(wèn)題,可嘗試升級(jí)Git版本到2.9.0以上并再次修改config。
補(bǔ)充說(shuō)明
除了使用指令修改config外也可直接找到配置文件修改。
在win中,git的config配置文件路徑分別為:
- local:在當(dāng)前項(xiàng)目的.git/config文件中,默認(rèn).git是隱藏文件
- global:在
%HOME%/.gitconfig
中,%HOME%
為系統(tǒng)自帶環(huán)境變量,一般為C:\Users\<username>
,相當(dāng)與linux的~。另外.gitconfig
文件可能也是隱藏的 - system:在git安裝目錄的
mingw64\etc\gitconfig
文件中
在linux中,git的config配置文件路徑分別為:
- local:也是在當(dāng)前項(xiàng)目的.git/config文件中
- global:在/.gitconfig中,為當(dāng)前用戶(hù)的主目錄
- system:在根目錄
/etc/gitconfig
文件中
參考
Stackoverflow--fatal: unable to get credential storage lock: File exists
Github--Can't deal with lock file .git-credentials.lock when exec git push in v2.8.3