git error fatal: Unable to create '<path>/.git/index.lock': File exists.
Platform Notice: Cloud and Data Center - This article applies equally to both cloud and data center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
When running git commands, an error is displayed pointing to a file: .git/index.lock.
1
2
3
fatal: Unable to create '<path>/.git/index.lock':
File exists.
If you are pushing to Bitbucket Cloud and get a similar error, but it is a remote error, please create a support ticket:
1
2
3
remote: error: cannot lock ref 'refs/heads/master':
Unable to create '<path>/./refs/heads/master.lock':
File exists.
Environment
Any git repository.
Diagnosis
When doing a local git write, like a git merge, you see the following error:
1
2
fatal: Unable to create '<path>/.git/index.lock':
File exists.
Make sure the error does not say 'remote error' and check to see if the file exists. If the file does not exist, the git process that created the file finished and exited or this is not the right Knowledge Base Article to follow.
Cause
Another git process is currently writing data to this repository.
OR
A git process exited early and was not able to remove the file before exiting. This file is used to make sure two git process do not write at the same time.
Solution
This issue is a local error, it affects just this repository. Check in your OS to make sure no other git process are running. If you can confirm no git process are running, you can remove the file with no issues.
Was this helpful?