Programmers learn & share
0 votes

Problem :

I am new to GIT. I have recently created a new repository with github desktop but I couldn’t add local repository for some reason in my react app. When I try to commit I get the error message as follows: “A lock file already exists in the repository, which blocks this operation from completing.”

I have tried to delete the package-lock.json file but it is not helping. My react build is not running. I have no idea what causes this issue.

  • GitHub Desktop version : 1.3.4
  • Operating system version : Windows 7Home Premium 64-Bit
by (7.5k points)   | 343 views

1 Answer

0 votes

Solution :

You will often face this issue when the Git crashes unexpectedly. Now to resolve this issue you need to go to your hidden .git directory shown in the error message and you need to delete the index.lock file located there.

You will need to enable the viewing hidden files and folders on Windows.

To access the log files you need to go to the file menu in GitHub Desktop and select Help > Show Logs in Finder (for macOS) or Explorer (for Windows). The log files are created daily.

For those are using Unix/Mac/etc

In your terminal when you are at project root just delete it manually if you can't see it use following command:

rm -rf ./.git/index.lock

After deleting the index.lock file you can do commit using GitHub Desktop again.

by (36.1k points)  
2,227 questions
2,734 answers
241 users