【发布时间】:2022-01-26 01:17:28
【问题描述】:
我使用 Git 进行版本控制。
最近,在 Git 中提交后,用于锁定 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
我正在使用翻译器。 谢谢。
【问题讨论】:
标签: git github intellij-idea locking