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