VS 2017 Git Local Commit DB.lock 每次提交时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47460039/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:11:48  来源:igfitidea点击:

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

gitvisual-studio

提问by alex Reid

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

Git 因致命错误而失败。错误:打开(“.vs/XXXXXX.Dev.Library/v15/Server/sqlite3/db.lock”):权限被拒绝致命:无法处理路径 .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.

这是 VS 2017 的全新安装,使用本地 git 存储库,然后才能同步到 Azure DevOps GIT。

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

我们可以手动删除锁定文件然后同步正常,但它严重减慢了开发过程(每次都必须关闭删除打开提交)。

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

有没有人知道这个问题的更好的长期解决方案?

回答by Matheus Lacerda

Just add the .vs folder to the .gitignorefile.

只需将 .vs 文件夹添加到.gitignore文件即可。

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

下面是 GitHub 的 .gitignore 模板集合中的 Visual Studio 模板,例如:https:
//github.com/github/gitignore/blob/master/VisualStudio.gitignore



If you have any trouble adding the .gitignore file, just follow these steps:

如果您在添加 .gitignore 文件时遇到任何问题,请按照以下步骤操作:

  1. On the Team Explorer's window, go to Settings.
  1. 在团队资源管理器的窗口中,转到设置。

Team Explorer - Settings

团队资源管理器 - 设置

  1. Then access Repository Settings.
  1. 然后访问存储库设置。

Repository Settings

存储库设置

  1. Finally, click Add in the Ignore File section.
  1. 最后,单击忽略文件部分中的添加。

enter image description here

在此处输入图片说明

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

完毕。;)
此默认文件已包含 .vs 文件夹。

enter image description here

在此处输入图片说明

回答by Siddarth Kanted

  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.
  1. .vs 文件夹不应提交。
  2. 在项目 git 根目录中创建一个名为“.gitignore”的文件。
  3. 在“.gitignore”文件中添加以下行“.vs/”。
  4. 现在提交你的项目。

enter image description here

在此处输入图片说明

回答by Jpsy

Step 1:
Add .vs/ to your .gitignore file (as said in other answers).

第 1 步:
将 .vs/ 添加到您的 .gitignore 文件(如其他答案中所述)。

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:

第 2 步:
重要的是要了解,如果 .vs/ 中的文件已添加到其中,则第 1 步不会从您当前的分支索引中删除它们。因此,通过发出以下命令清除您的活动分支:

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.

第 3 步:
最好立即对项目的所有其他活动分支重复第 1 步和第 2 步。
否则当切换到一个未清理的分支时,你很容易再次面临同样的问题。

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

专业提示:
您可能希望使用 VisualStudio 的官方 .gitingore 模板而不是第 1 步,该模板涵盖的不仅仅是 .vs 路径:
https: //github.com/github/gitignore/blob/master/VisualStudio.gitignore
(但仍然不要忘记步骤 2 和 3。)

回答by Bernard Oreva

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

VS 2017 Git Local Commit DB.lock 每次提交时出错

This issue must have been caused by a corrupt .ignore file.

此问题一定是由损坏的 .ignore 文件引起的。

If your IDE is Visual Studio please follow these steps to resolve this issue:

如果您的 IDE 是 Visual Studio,请按照以下步骤解决此问题:

  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
  1. 从项目文件夹中删除 .gitignore 文件
  2. 转到团队资源管理器
  3. 在团队资源管理器中转到主页
  4. 前往设置
  5. 在 GIT 下,单击存储库设置
  6. 在 - 忽略和属性文件下 - 在忽略文件下 - 单击添加。您应该会看到一条通知,提示已成功创建忽略文件
  7. 构建您的解决方案。一旦构建成功,将需要一些时间并创建一个新的 .ignore 文件
  8. 您现在应该能够提交和推送而不会出现任何问题

NB: Bear in mind that your version of visual studio might place these options differently. I am using Visual Studio 2019 Community Edition.

注意:请记住,您的 Visual Studio 版本可能会以不同的方式放置这些选项。我正在使用 Visual Studio 2019 社区版。

回答by Bernard Oreva

I had the same issue but I've resolved by creating the .gitignore file.

我有同样的问题,但我已经通过创建 .gitignore 文件解决了。

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.

我还发现了一种解决方法,它只是从 .vs 文件夹中删除 db.lock 文件,但您必须每次都这样做,并且长时间这样做会使这成为一个烦人的操作。

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!

解决此问题的最佳方法是按照之前的建议创建 .gitignore 文件,但我认为最好提及此解决方法,仅用于一般知识目的!

Regards, Tony Grinton

问候,托尼·格林顿

回答by Peter Horsb?ll M?ller

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

我不是直接通过 Visual Studio 使用 Git,而是使用 Git 桌面客户端。

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

然而,我确实遇到了类似的错误,但通过在将更改提交给 master 之前关闭 Visual Studio 解决了它。

回答by Hamit YILDIRIM

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

如果您使用的是像 Visual Studio 这样的 IDE 并且在发送命令时它是打开的,请关闭 IDE 并重试

git add .

and other commands, it will workout

和其他命令,它会锻炼

回答by Ram

For me steps below helped:

对我来说,以下步骤有帮助:

  • Close Visual Studio 2019
  • Delete .vs folder in the Project
  • Reopen the Project, .vs folder is automatically created
  • Done
  • 关闭 Visual Studio 2019
  • 删除项目中的 .vs 文件夹
  • 重新打开工程,.vs文件夹自动创建
  • 完毕

回答by Super Jade

My automatically generated .gitignorefile contained /.vsinstead of .vs/. Fixing this typo fixed the problem!

我自动生成的.gitignore文件包含/.vs而不是.vs/. 修复这个错字解决了问题!

回答by Jaydeep Shil

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.

对我来说,我错误地删除了这两个文件,在撤消这两个文件并添加到我的更改中后,我能够将更改提交到 git。