Git ignoring folder not in gitignore
I have a git directory as follows:
My .gitignore
contains:
git status
returns the following:
git status --ignored
returns:
Directory template
is a regular directory that isn't a part of any other git project. It contains the following:
git config --get core.excludesfile
returns:
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
.