Monday, September 29, 2025

Simple way to fix git .lock file already exist error when fetch or pull rebase a branch

 Not sure why sometimes git reports an error of .lock file already exists error in .git ref folder, although actually the file or even the mentioned folder does not exist.

Tried many ways mentioned in web but none of them works in my case. Clone and download all dependency packages again will take a lot of time and it is not a good choice.

Eventually, a simple workaround is just clone the repository again, and then copy the just downloaded .git or whole project folder to the existing project folder, so as to override the .git and source folder. Then it gets a clean git history and run git fetch or git pull --rebase will not cause any issue. 

May not be the best solution and definitely a working solution :)

No comments:

Post a Comment