Git will not search project/etc/downloads/
for any files because you have configured it to ignore project/etc/*
. The “unanchored” !README.txt
pattern is only good for negating the exclusion of entries in directories that will be searched (i.e. directories that have not themselves been excluded).
If you exclude project/etc/
, Git will never search that directory, so negated exclusions can never apply to its contents (not even one so explicit as !project/etc/important-file
!—maybe this could be considered a bug?).
However, if you exclude project/etc/*
, Git will search that directory, and negated exclusions can apply to its contents. A person might realize that the second pattern will always match all files and assign the same meaning to both patterns, but Git, but Git treats them differently.
You might consider project/etc/
and project/etc/*
to mean the same thing, but Git treats them differently because it does not “realize” that the second one will match everything in the directory.
So, to get !README.txt
to apply in projects/etc/downloads/
you will have to unignore the directory but ignore its contents before the !README
pattern:
project/etc/*
# "unignore, but ignore the immediate contents of" project/etc/downloads
# so that subsequent negated patterns can apply to the immediate contents
!project/etc/downloads/
project/etc/downloads/*
!README.txt