VS 2017 Git Local Commit DB.lock error on every commit
Just add the .vs folder to the .gitignore file.
Here is the template for Visual Studio from GitHub's collection of .gitignore templates, as an example:
https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
If you have any trouble adding the .gitignore file, just follow these steps:
- On the Team Explorer's window, go to Settings.
- Then access Repository Settings.
- Finally, click Add in the Ignore File section.
Done. ;)
This default file already includes the .vs folder.
- .vs folder should not be committed.
- create a file with name ".gitignore" inside the projects git root directory.
- Add the following line ".vs/" in ".gitignore" file.
- Now commit your project.
Step 1:
Add .vs/ to your .gitignore file (as said in other answers).
Step 2:
It is important to understand, that step 1 WILL NOT remove files within .vs/ from your current branch index, if they have already been added to it. So clear your active branch by issuing:
git rm --cached -r .vs/*
Step 3:
Best to immediately repeat steps 1 and 2 for all other active branches of your project as well.
Otherwise you will easily face the same problems again when switching to an uncleaned branch.
Pro tip:
Instead of step 1 you may want to to use this official .gitingore template for VisualStudio that covers much more than just the .vs path:
https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
(But still don't forget steps 2 and 3.)
VS 2017 Git Local Commit DB.lock error on every commit
This issue must have been caused by a corrupt .ignore file.
If your IDE is Visual Studio please follow these steps to resolve this issue:
- Delete the .gitignore file from your project folder
- Go to Team Explorer
- Go to Home in Team Explorer
- Go to Settings
- Under GIT, Click Repository Settings
- Under - Ignore & Attributes Files - Under Ignore File - Click Add. You should see a notification that the Ignore File has been successfully created
- Build your solution. It will take a little while and create a new .ignore file once build is successful
- You should now be able to Commit and Push without any further issue
NB: Bear in mind that your version of visual studio might place these options differently. I am using Visual Studio 2019 Community Edition.
I had the same issue but I've resolved by creating the .gitignore file.
I've also found a workaround that simply consists on removing db.lock file from the .vs folder but you have to do it every single time and doing this for long makes this an annoying operation.
The best way to solve this issue is to create the .gitignore file as suggested before, but I think that is good to mention also this workaround, just to general knowledge purpose!
Regards, Tony Grinton