Git Lock Errors

Knowledge Drop

Last tested: March 2021

If you get an error with a git operation that mentions a lock, there is probably a lock file.

These files are usually temporary and will go away if you wait a sec and try the operation again.

If you have command line access to the git repository, you can run git gc to figure out where the lock file is - you may see something like:
fatal: Unable to create '/mnt/efs/models/<project-name>/.git/refs/heads/master.lock': File exists.

If no other git process is currently running, this probably means a git process crashed in this repository earlier. Make sure no other git process is running and remove the file manually to continue.