Open In App

Git – A lock file already exists in the repository, which blocks this operation from completing

Here we will create a new repository with GitHub desktop in a small illustrative react app. Here when we commit we are supposed to get an error in order to illustrate via error message as a lock file already exists in the repository, which blocks this operation from completing. Do check here we are demonstrating GitHub Desktop version1.3.4 on Windows OS.

Steps to Reproduce

  1. Add Local Repository. Choose Repository. Get redirected to create a new repository.
  2. Create a new repository in the project folder
  3. Commit(Try to) and get the error message: A lock file already exists in the repository, which blocks this operation from completing.

Expected Behavior: Commit goes through



Actual Behavior: Get Error Message: A lock file already exists in the repository, which blocks this operation from completing.

 

Error: If you go to commit your file in GitHub Desktop then you get this error.



We need to follow the below steps in order to solve the above ambiguity that is as follows depicted through visual aid for better understanding as here we are using GitHub Desktop: 

Step 1: Open the folder in your system.

 

Step 2: Click on { 3. (…) after options }.

 

Step 3: Click view

 

Step 4: Hidden file and folder > Show hidden file and folder ( click on ) and click on ok.

 

Step 5: Open the .git folder and delete the index.lock.

 

Step 6: Now, open GitHub Desktop

 

Step 7: Click on the commit.

 

As seen from the above media Commit goes through and our problem is solved earlier where we were getting an error message. 

Article Tags :
Git