cmder: Git: fatal: Unable to create '.git/index.lock': File exists.
Git is unable to create .git/index.lock
file because it already exists. Steps to reproduce using files that are readily available:
- Goto https://wordpress.org/download/ and download WordPress ZIP archive.
- Extract to a directory.
- Open Cmder and change directory where WordPress was extracted.
- Init directory using:
git init
- Configure
user.name
anduser.email
git config user.name "test"
git config user.email "test@example.com"
- Add all files.
git add -A
- Commit files.
git commit -m "test"
An error like this shows up:
fatal: Unable to create 'Z:/a/.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.
- Listing the
.git
directory shows that anindex.lock
file exists. - Open Task Manager and multiple Git for Windows processes are still running.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 2
- Comments: 40 (7 by maintainers)
Problem:
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.
Solution:
rm .git/index.lock
The problem is definitely with Cmder or ConEmu. It spawns a git process that never closes each time it displays the prompt line (so if you are in a directory which is also a git repo, on each enter press you get a new process spawned). One of those git processes produces a index.lock file which prevents any other git process to operate on the repo.
For anyone ran into the same issue with index lock, there’s a workaround that disabling Settings -> Git Extensions -> Performance -> Show number of changed files on commit button so that Git Extensions won’t call git status as soon as any file updates which blocking the current processing git commands and introducing the lock.
Hope this help for you guys.
If you are getting the same error then please follow the below steps.
goto .git in the folder location delete the index.lock file
now check everything will work
solution : rm -Force ./.git/index.lock
@WillJE Why should anyone have to unlock it? Something within the application keeps causing it to lock. Manually unlocking it gets you by one time, but this is a recurring issue. Your saying we should have to manually go in and unlock it every time it glitches out? That is not a solution, it’s called a band-aid fix.
it’s locked,you can use GUI to unlock it and then everything will be fine, i just tried it
Fixed in #1101