Git提交時(shí)提示"fatal unable to get credential storage lock File exists"的解決辦法

問(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=storecredential.helper=manager

解決辦法

在git的config中找到credential.helper項(xiàng),刪除其中一項(xiàng)。

  1. 首先要確定是否是有config中credential.helper重復(fù)引起的問(wèn)題,執(zhí)行git config -l可查看所有參數(shù)
  2. 確定參數(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)
  3. 如果是在系統(tǒng)參數(shù)中,則執(zhí)行git config --system --unset credential.helper即可刪除system中的此參數(shù)配置。如果是在local或global則將其中的system替換即可。
  4. 如果依然有問(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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容