简体   繁体   English

Git 忽略仍列在未跟踪列表中的文件

[英]Git ignore files still listed in untracked list

I try to ignore build files from VS, which are located on obj and bin catalogs.我尝试忽略来自 VS 的构建文件,这些文件位于objbin目录中。

In order to do that I specified ( .vs is just catalog with some cached data, which is unnecesasry, I don't want that either):为了做到这一点,我指定了( .vs只是包含一些缓存数据的目录,这是不必要的,我也不希望那样):

**/.vs/**
.vs/
**/obj/**
obj/
**/bin/**
bin/

But even though, they still show in untracked files list and when I git add them, all these catalogs are added with all its content.但是尽管如此,它们仍然显示在未跟踪的文件列表中,当我git add它们时,所有这些目录及其所有内容都会被添加。

I know this has been talked about many times, but nothing seems to work for me.我知道这已经被讨论过很多次了,但似乎对我没有任何作用。

I tried pushing .gitignore alone to make it take effect, but did not work.我尝试单独推送.gitignore以使其生效,但没有用。

I tried using slashes, forward slashes, double slashes, did not work.我试过使用斜杠、正斜杠、双斜杠,都没有用。

I tried also following this solution , did not work either...我也试过按照这个解决方案,也没有用......

I think I miss something really basic, but don't know what it might be.我想我错过了一些非常基本的东西,但不知道它可能是什么。

The solution was simple, but really unexpected (at least for me), so I want to leave the answer here to all people that are going to run into the same problem.解决方案很简单,但确实出乎意料(至少对我而言),所以我想把答案留给所有将要遇到同样问题的人。 (also because I didn't find any clue pointing to that issue). (也是因为我没有找到任何指向该问题的线索)。

The thing that went wrong was encoding of a .gitignore file (it was UCS-2 BE BOM) - that caused GIT not to read it properly.出错的地方是.gitignore文件的编码(它是 UCS-2 BE BOM)——导致 GIT 无法正确读取它。 As soon as I set it to UTF-8 it worked.一旦我将它设置为UTF-8它就起作用了。

Don't know what caused the encoding of a file, but it certainly disabled feature of .gitignore file.不知道是什么导致了文件的编码,但它肯定禁用了.gitignore文件的功能。

And obviously, file itself can be simplified (I posted expanded version to show all my attempts) to this:显然,文件本身可以简化为(我发布了扩展版本来展示我所有的尝试):

**/.vs/**
**/bin/**
**/obj/**

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM