VS 2017 Git Local Commit DB.lock error on every commit

GitVisual Studio

Git Problem Overview


We are getting this error on every local commit:

> Git failed with a fatal error.error: > open(".vs/XXXXXX.Dev.Library/v15/Server/sqlite3/db.lock"): Permission > deniedfatal: Unable to process path > .vs/XXXXXX.Dev.Library/v15/Server/sqlite3/db.lock

This is a brand new installation of VS 2017 using the local git repository before it can sync to Azure DevOps GIT.

We can manually delete the lock file and then sync fine, but it seriously slows down the development process (having to close, delete, open, commit every time).

Does anyone know a better long-term fix for this issue?

Git Solutions


Solution 1 - Git

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:

  1. On the Team Explorer's window, go to Settings.

Team Explorer - Settings

  1. Then access Repository Settings.

Repository Settings

  1. Finally, click Add in the Ignore File section.

enter image description here

Done. ;)
This default file already includes the .vs folder.

enter image description here

Solution 2 - Git

  1. .vs folder should not be committed.
  2. create a file with name ".gitignore" inside the projects git root directory.
  3. Add the following line ".vs/" in ".gitignore" file.
  4. Now commit your project.

enter image description here

Solution 3 - Git

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.)

Solution 4 - Git

https://stackoverflow.com/questions/47460039/vs-2017-git-local-commit-db-lock-error-on-every-commit?rq=1

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:

  1. Delete the .gitignore file from your project folder
  2. Go to Team Explorer
  3. Go to Home in Team Explorer
  4. Go to Settings
  5. Under GIT, Click Repository Settings
  6. Under - Ignore & Attributes Files - Under Ignore File - Click Add. You should see a notification that the Ignore File has been successfully created
  7. Build your solution. It will take a little while and create a new .ignore file once build is successful
  8. 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.

Solution 5 - Git

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

Solution 6 - Git

My automatically generated .gitignore file contained /.vs instead of .vs/. Fixing this typo fixed the problem!

Solution 7 - Git

I'm not using Git directly thru Visual Studio but using the Git Desktop client.

I did however get a similar error but solved it by closing Visual Studio before Committing changes to master.

Solution 8 - Git

if you are using an IDE like visual studio and it is open while you sending commands close IDE and try again

git add .

and other commands, it will workout

Solution 9 - Git

For me steps below helped:

  • Close Visual Studio 2019
  • Delete .vs folder in the Project
  • Reopen the Project, .vs folder is automatically created
  • Done

Solution 10 - Git

enter image description here

For me these two files I have deleted by mistake, after undo these two files and get added in my changes, I was able to commit my changes to git.

Solution 11 - Git

Had this and my .gitignore was inside my project folder, but the main git folders were at the solution level. Moving .gitignore out to the solution/git level folders worked. Still not sure how it got there but...

Solution 12 - Git

dotnet now includes a command for gitignore.

Open cmd.exe from your project folder and type:

dotnet new gitignore

Solution 13 - Git

Besides these great answers,

I also checked username, email in VS2017 > Team Explorer > Settings >

  • Global settings
  • Repository Settings

Basically verified vs Bitbucket credentials (click the 'clone' link to see your given username/repo), since there could be a mismatch.

That said I believe the more important check (particularly if working on same repo from 2x different machines) is the URL to remote repo.

Solution 14 - Git

I had the same error before, and found that the problem was because I didn't close visual studio

Solution 15 - Git

Try to copy the file in to your directory manually (C:\Users\Admin\AppData\Local\Temp\WebSitePublish\digisol--1147805695\obj\Debug\Package\PackageTmp.vs\digisol\v15\Server\sqlite3 )

Solution 16 - Git

I had done above solutions , finally this works solved my problem :

  • Close the visual studio

  • Run the git bash in the project folder

  • Write :

    git add .

    git commit -m "[your comment]"

    git push

Solution 17 - Git

To resolve this issue is simple. First Close, the Visual Studio and open the Windows Explorer, Go to location folder .vs and open folder properties and check the option hidden

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionalex ReidView Question on Stackoverflow
Solution 1 - GitMatheus LacerdaView Answer on Stackoverflow
Solution 2 - GitSiddarth KantedView Answer on Stackoverflow
Solution 3 - GitJpsyView Answer on Stackoverflow
Solution 4 - GitBernard OrevaView Answer on Stackoverflow
Solution 5 - Gituser9557542View Answer on Stackoverflow
Solution 6 - GitSuper JadeView Answer on Stackoverflow
Solution 7 - GitPeter Horsbøll MøllerView Answer on Stackoverflow
Solution 8 - GitHamit YILDIRIMView Answer on Stackoverflow
Solution 9 - GitRamView Answer on Stackoverflow
Solution 10 - GitJaydeep ShilView Answer on Stackoverflow
Solution 11 - GitJoe HealyView Answer on Stackoverflow
Solution 12 - GitAniView Answer on Stackoverflow
Solution 13 - GitEricMcDView Answer on Stackoverflow
Solution 14 - GitAchraf El HadiView Answer on Stackoverflow
Solution 15 - GitRaviteja VView Answer on Stackoverflow
Solution 16 - GitMostafa HydarzadehView Answer on Stackoverflow
Solution 17 - GitWellington MatosView Answer on Stackoverflow