desktop: A lock file already exists in the repository, which blocks this operation from completing.

Description

Ive created a new repository with github desktop( i couldnt add local repository for some reason) in my small react app. When i want to commit i get the error message :A lock file already exists in the repository, which blocks this operation from completing.

Ive delete the package-lock.json file but it doesnt help. react build is not running. no idea what causes this. thanks for your help

Version

  • GitHub Desktop:1.3.4
  • Operating system: Windows 7Home Premium 64-Bit

Steps to Reproduce

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

Expected Behavior

Commit goes trough

Actual Behavior

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

Additional Information

Logs

2018-08-26.desktop.production.log

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 19
  • Comments: 39 (7 by maintainers)

Most upvoted comments

@simhox thank you for updating the issue body and uploading the log file! Here’s the related error:

fatal: Unable to create 'C:/Alles/Programme/react/todoapp/todo/.git/index.lock': File exists.

This often happens when Git crashes unexpectedly. What you will want to do to resolve this is go to the hidden .git directory show in the error message and delete the index.lock file located there. You will need to enable viewing hidden files and folders on Windows. After deleting that index.lock file you should be able to commit using GitHub Desktop again.

Let me know if you run into any further issues.

Deleting the index.lock file sorted this issue for me. I also made sure to restart the Git Desktop Client as well. Thanks.

For those on Unix/Mac/etc

In your terminal (when at your project root) - delete it manually if you can’t see it

rm -rf ./.git/index.lock

1.) Go Your GitHub folder. The Main GitHub Folder 2.) ensure your can see the hidden folders 3.) open .git (which is hidden) 4.) delete index.lock file 5.) This should solve the problem

Enjoy Coding

@cwbiggs you might need to go in and remove the .git/index.lock file if it isn’t cleaned up as part of normal operations

Removing rm -f .git/index.lock does not always help. It is necessary to close the client by force through the Task Manager (memory eats ~1.1 GB). The problem appears when indexing more than 500 files. Perhaps some of them were damaged.

I have no index.lock file from the .git subdirectory.

Of course. Thank you for being so nice about it and explaining it too. I’ve edited the initial Post to have (hopefully) all the information you need. I will now check out the possibly related issue. Thank you again.

I have no index.lock file from the .git subdirectory.

So, I was also having this issue. After reading through my log history, and was going to post this same exact problem. I also found my index.lock file. Mine was located in my project folder with my actual UE4 project. ie: " C:\Users\blake\OneDrive\Documents\Unreal Projects\MyProject3.git" was my actual file location where I save to. So, I guess if you know where to find the unreal project directory you should be able to find this.

1.) Go Your GitHub folder. The Main GitHub Folder 2.) ensure your can see the hidden folders 3.) open .git (which is hidden) 4.) delete index.lock file 5.) This should solve the problem

Enjoy Coding

Hey Thanks Its working 😃

I’m on Windows 11 and the index.lock did not exist in the .git folder as expected. I resorted to searching the .git folder for any file containing “lock” and found a lock file named {reponame}.lock file in a subdirectory.

Deleted that file and the issue went away. YMMV

Deleting the index.lock file worked for me. Thank You!

I also had this same issue. I was unable to locate any lock file in the repository as others have mentioned. I guess I just won’t be using Github desktop? ¯_(ツ)_/¯

search *.lock file you will definetely get it may be in remote folder (.git\refs\remotes\origin) 💯

cd .git
rm -rf index.lock

I can confirm this works flawlessly. I didn’t even have to restart desktop! THANK YOU.

@nikonorovd are you still experiencing this error? If so, it would be helpful if you could upload a log file from GitHub Desktop.

To access the log files go to the file menu in GitHub Desktop and select Help > Show Logs in Finder (macOS) or Explorer (Windows). The log files are created daily – please send over a log file as an attachment from a day where you experienced the issue.

I had the same issue. Deleting the lockfile in C:/Users/Me/Documents/GitHub/GISDev/.git resolved it.