0

This is the error I get when I attempt to add files to my git repo (git add.):

fatal: Unable to create 'C:/Users/path/to/my/file/.git/index.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.

I've seen the other questions on here about how to remove .git/index.lock from the repo, but running git rm -f ./.git/index.lock is just not working for me. Is there a way I can remove it manually? Or is my last resort to create a new git repo and push all my files into a new repo? I've never had this happen before...

2
  • 1
    You don't do git rm ..., you just do rm ... . Commented Nov 10, 2017 at 13:56
  • Oh wow....that worked. Thanks so much! Commented Nov 10, 2017 at 14:09

2 Answers 2

1

git rm is used for removing files in the working directory that are being tracked by the version control system. The lock file is not part of your project so you should remove it the same way you’d remove any file on your system, e.g., using the rm command.

Lock files

Before doing so, I’d suggest checking all running processes to make sure that there isn’t some Git process running in the background that is still keeping the lock file open. Lock files are automatically removed when Git commands complete; the only reason a lock file should be existing without a corresponding process in operation is if it crashed or somehow stopped suddenly without time to clean up after itself.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks so much for the clarification.....I was wondering how that worked. I was able to solve the issue with the answer someone posted yesterday.
@CandisW Cool. I've added a bit more clarification on lock files so that it may be of help to other users.
0

For my case I had two Phpstorm windows open. Closing one got the command work. I guess both windows were running git concurrently.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.