git
resource_error
ai_generated
true
fatal: Unable to create '.git/index.lock': File exists.
ID: git/commit-not-possible-because-index-is-locked
95%Fix Rate
85%Confidence
1Evidence
2023-03-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| git 2.30.0 | active | — | — | — |
| git 2.39.0 | active | — | — | — |
| git 2.42.0 | active | — | — | — |
Root Cause
A previous git command crashed or is still running, leaving the index.lock file, which prevents any new write operations.
generic中文
之前的 git 命令崩溃或仍在运行,留下了 index.lock 文件,阻止任何新的写入操作。
Official Documentation
https://git-scm.com/docs/git-lockfileWorkarounds
-
95% success Remove the lock file manually: rm -f .git/index.lock
Remove the lock file manually: rm -f .git/index.lock
-
85% success Check for hanging git processes: ps aux | grep git, then kill them before removing the lock file.
Check for hanging git processes: ps aux | grep git, then kill them before removing the lock file.
-
90% success If using Windows, use del .git\index.lock from the repository root.
If using Windows, use del .git\index.lock from the repository root.
中文步骤
Remove the lock file manually: rm -f .git/index.lock
Check for hanging git processes: ps aux | grep git, then kill them before removing the lock file.
If using Windows, use del .git\index.lock from the repository root.
Dead Ends
Common approaches that don't work:
-
95% fail
Destroys all commit history and branches; overkill for a simple lock file issue.
-
100% fail
The lock file persists, so the same error occurs again.
-
80% fail
Does not remove the lock file; may lose uncommitted changes without fixing the issue.