Thanks Derrick. > What is unclear to me is what exactly "match a directory" means. > If we ignore a directory, then we ignore everything inside it (until > another pattern says we should care about it), but the converse > should also hold: if we have a pattern like "!data/**/", then that > should mean "include everything inside data/<A>/ where <A> is any > directory name". I think if we consider directory and files separately, it would be more clear. If a pattern in gitignore matches a directory, it is just about that directory and not about its contents. The contents are ignored by another rule which states: > It is not possible to re-include a file if a parent directory of that file is excluded. In our test case, the "data1" directory is ignored by the "data/**" pattern. However, the contents are ignored by two rules. One of them is that the parent ("data1") is not tracked. Another one is that the "data/**" pattern matches them. By adding the "!data/**/" pattern, the "data1" directory is re-included, but its contents are still ignored by the "data/**" pattern. I hope this will help to make the rules more clear. Thanks Danial