gitignore不适用于Visual Studio [英] gitignore is not working with Visual Studio

查看:92
本文介绍了gitignore不适用于Visual Studio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将我的项目更改从使用Visual Studio 2017的C#项目提交到我的私有gitea存储库.不幸的是,生成输出(例如bin,debug)以及VS缓存文件夹.vs总是被添加到更改列表中.

I am trying to commit&push my project changes from a C# project using Visual Studio 2017 to my private gitea repository. Unfortunately build outputs like bin, debug but also the VS cache folder .vs is always beeing added to the change list.

当我输入"git add"时.我收到以下错误:

When i type 'git add .' i get the following error:

error: open(".vs/xyz/v15/Server/sqlite3/db.lock"): Permission denied
error: unable to index file .vs/xyz/v15/Server/sqlite3/db.lock
fatal: adding files failed

对我来说,问题很明显.Git尝试将.vs子文件夹添加到更改列表中,但无法这样做,因为Visual Studio在数据库上具有锁定.

to me the problem is clear. Git tries to add the .vs subfolder to the change list, but is not able to do so because Visual Studio has a lock on the database.

我已经从此处下载了.gitignore文件:

I have downloaded a .gitignore file from here:

https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

将其复制到项目文件夹的根目录,并将其重命名为.gitignore.我检查了此文件和文件夹的权限,并且该用户具有完整的写入权限(顺便说一句,我正在使用Windows 10).

copied it to the root of the project folder and renamed it to .gitignore. I checked the permission of this file and the folder, and the user has full write permissions (i am using Windows 10 by the way).

在命令行中,我已经这样做了:

In the command line i have done this:

git rm -r --cached .

从存储库中删除了我所有的源文件.我用

Which removed all my source files from the repository. I commited this changed with

git commit -am "removed source files"

并使用

git add .\.gitignore
git commit -am "readded gitignore"

当我使用命令

git check-ignore -v .vs

我没有任何输出,以某种方式告诉我gitignore文件没有被git使用.

i get no output, which somehow tells me, that the gitignore file is not used by git.

我正在将git用于Windows 2.17.1.windows.2.此外,我还安装了tortoiseGit,可用于其他项目(我不确定它是否会干扰git,所以我会提到它).

I am using git for windows version 2.17.1.windows.2. Additionally i have tortoiseGit installed, which i use for other projects (i'm not sure it it interferes with git so i mention it).

推荐答案

好的,我已经解决了问题!这是一个棘手的问题.根据我的Notepad ++ ,. gitignore文件编码设置为"UCS2 BE BOM".我将编码转换为UTF-8,瞧,我可以添加文件了.

ok, i got the issue resolved! This one was a tricky one. According to my Notepad++ the .gitignore file encoding was set to "UCS2 BE BOM". I converted the encoding to UTF-8 and voila i was able to add my files.

这篇关于gitignore不适用于Visual Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆