Search code examples
gitgitignore

Git ignore files still listed in untracked list


I try to ignore build files from VS, which are located on obj and bin catalogs.

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/
**/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.

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.

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.


Solution

  • 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. As soon as I set it to UTF-8 it worked.

    Don't know what caused the encoding of a file, but it certainly disabled feature of .gitignore file.

    And obviously, file itself can be simplified (I posted expanded version to show all my attempts) to this:

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