.gitignore not ignoring files correctly

85 Views Asked by At

I have a TeX project. I want to ignore some file extensions which I have added in the .gitignore file, but they are still shown as untracked files in git status. How to make git not track these files? A figure is added showing the VS code workspace along with the staged area git ls-files and output of git status. You can see the message about the same files being untracked in color red.

enter image description here

2

There are 2 best solutions below

1
rupsagar On BEST ANSWER

Fixed it. It works if I create the .gitignore using Windows Subsystem for Linux (Ubuntu). It does not work if created through Windows 10 VS Code editor. A similar thing is also mentioned in this solution. It also worked when I created the .gitignore file using echo in Git Bash which is a Linux environment. Strange indeed! It probably has something to do with the carriage return (CR) and line feed (LF).

1
unDeadHerbs On

It looks like you have spaces before your patterns in the file. This space is treated as part of the pattern, not an indentation.

It'd be easier to tell this if you included text rather than a screenshot.