我使用 Git 進行版本控制。
最近在Git中commit后,用于鎖定HEAD的.lock檔案一直存在(.git/HEAD.lock)。
Git 行程已死,我可以使用 rm 洗掉 HEAD.lock 檔案。
如果你在 HEAD.lock 仍然完整的情況下提交,Git 將因錯誤而崩潰。
在我提交 50 之前,它一直運行良好,但從那時起它的行為就很奇怪。
這個問題并不能完全阻止提交,但它確實使rm .git/HEAD.lock每次在提交之前運行都有問題。
git update-git-for-windows自從出現此問題以來,我一直在運行,但我仍然多次遇到此問題。
日志:
04:12:11.966: [SameProject] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false add --ignore-errors -A -f -- path/to/file.file path/to/file2.file path/to/file3.file
04:12:12.415: [SameProject] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false commit -F C:\Users\UserA\AppData\Local\Temp\git-commit-msg-.txt --
fatal: cannot lock ref 'HEAD': Unable to create 'C:/path/to/.git/HEAD.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.
這些命令是從 IntelliJ IDEA 運行的,我認為 IDEA 引起了某些問題,但是查看命令,我不這么認為。
說到 git,我是個菜鳥,但我認為 .git 目錄中的索引或配置不知何故損壞了,但我不記得做了強制推送或強制退出。
我只是嘗試提交并再次遇到同樣的問題。當時,Git 日志中有一個令人不安的日志。
04:37:56.500: [SameProject] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false add --ignore-errors -A -f -- path/to/fileC.file
04:37:56.585: [SameProject] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false commit -F C:\Users\UserA\AppData\Local\Temp\git-commit-msg-.txt --
warning: unable to unlink 'C:/path/to/.git/HEAD.lock': Invalid argument
我正在使用一個翻譯系統。謝謝你。
uj5u.com熱心網友回復:
首先嘗試相同的序列,形成 IntelliJ IDEA,然后重新啟動,以盡量減少可能保留該HEAD.lock檔案句柄的其他行程的存在。
HEAD.lock仍然是適用于 Windows 的當前版本的 Git 的問題,如issue 2531和commit 3c769b9 所示。
如果重新啟動后仍然失敗,請關閉 IntelliJ IDEA,然后嘗試從命令列提交,以查看問題是否仍然存在。
該OP Peyang總結了評論:
我不知道有問題。
如果我從命令列運行git,它仍然無法取消鏈接,但會詢問我是否要重試,如??果我運行y,它會成功完成提交。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/395060.html
