Unable to create 'D:/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.
Pull operation failed.
翻譯:另一個git進程似乎正在這個存儲庫中運行,例如 由“git commit”打開的編輯器。請確保所有流程終止,然后重試。如果它仍然失敗,一個git進程可能已在此存儲庫中崩潰:手動刪除文件以繼續。
原因分析
.git下的index.lock文件,在進行某些比較費時的git操作時自動生成,操作結束后自動刪除,相當於一個鎖定文件,目的在於防止對一個目錄同時進行多個操作。有時強制關閉進行中的git操作,這個文件沒有被自動刪除,之后就無法進行其他git操作,必須手動刪除。
解決方法
- 方法一:找到.git/index.lock文件,直接刪除即可;
如果在linux上的話,執行rm刪除命令:rm -f .git/index.lock - 方法二:執行git命令:
git clean -f .git/index.lock