git操作顯示 /.git/index.lock

git操作提示,如下

fatal: Unable to create '/Users/yu/xxx/xxx/.git/index.lock': File exists.

Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.

造成的原因是在某些比較費時的git操作時自動生成 index.lock文件,操作結(jié)束后自動刪除,相當(dāng)于一個鎖定文件,目的在于防止對一個目錄同時進(jìn)行多個操作。
有時強制關(guān)閉進(jìn)行中的git操作,這個文件沒有被自動刪除,之后你就無法進(jìn)行其他操作,必須手動刪除,進(jìn)入.git文件中刪除,如果沒有這個.git文件夾 打開顯示隱藏文件。如果沒有看見.git文件夾,可以直接用命令
rm -f ./.git/index.lock

之后就可以正常使用。

參考:https://blog.csdn.net/u010227042/article/details/124516885

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容