EliteRaceElephant
EliteRaceElephant

Reputation: 8162

Intellij claims index.lock exists when it does not

Problem:

You use the VCS system in Intellij and try to commit stuff. Commit fails and Intellij claims that index.lock exists. You check .git/index.lock in your repo directory and find out that it does indeed not exist.

Setup:

I tried creating a an index.lock file manually and then deleting it with git bash and also with Windows cmd. Did not work. I checked that there were no other programs using git. I restarted my PC and made sure nothing used Git.

I used Git Bash and committed manually without Intellij. Works perfectly fine. But after that the VCS commit in Intellij still claims that index.lock exists.

Similar questions that line out solutions that did not work: Git - fatal: Unable to create '/path/my_project/.git/index.lock': File exists

Upvotes: 2

Views: 1485

Answers (2)

EliteRaceElephant
EliteRaceElephant

Reputation: 8162

index.lock does clearly not exist and it still refues to commit.

Solution:

  • Create index.lock in windows explorer in the .git directory.
  • Open the terminal in Intellij
  • Type: rm .git\index.lock

You can commit again. Wierd thing is that Intellij terminal just uses basic Windows cmd commands. I tried plain Windows cmd as lined out in other answers but it did not work. Only the terminal in Intellij works.

Upvotes: 4

Dmitrii Smirnov
Dmitrii Smirnov

Reputation: 7528

IntelliJ uses the external git client, so it was definitely git claiming the file exists. As a wild guess, there could be 2 git repositories in the project and the lock existed in one of them. It is really hard to tell without the logs, so if you face the issue again, please submit a bug report as proposed in the comments.

Upvotes: 2

Related Questions