Git ignoring folder not in gitignore

I have a git directory as follows:

enter image description here

My .gitignore contains:

enter image description here

git status returns the following:

enter image description here

git status --ignored returns:

enter image description here

Directory template is a regular directory that isn't a part of any other git project. It contains the following:

enter image description here

git config --get core.excludesfile returns:

enter image description here

Any ideas why git is ignoring the directory template ? I even deleted the .git folder and re-initialized git but still the same thing is happening.


Git doesn't track folders, only files. It looks like you've excluded every type of file that's likely to live in that folder since the ignore of *.css, *.jpd etc is recursive actors all subfolders. If there are no files left in the templates folder, then get won't track it.


You can use the function check-ignore to debug this problem:

git check-ignore -v template/

The output will be in the following format:

someGitignoreFile:123:someRule   template/

...pointing you to the exact gitignore file, line number and particular ignore rule that led to the exclusion of template/.

If this comes up empty, then the next possibility is that even though the folder itself is technically not ignored, every single file inside of it is, and since Git tracks files and not empty folders (you cannot add an empty folder to the index), this would have the same result and is abbreviated in git status --ignored as showing the whole folder as ignored. You could check for that by going through all the files and checking them check-ignore as well - in your case it's possible that for example there are only *.html, *.png and *.js files inside template/, all of which you ignored in your .gitignore.