> On Mon, Oct 07, 2013 at 07:24:11AM -0400, Jeff King wrote:
>> However, one thing I expected to work but didn't is:
>> echo '*' >.gitignore
>> echo '!*' >my_dir/.gitignore
>> That _does_ work for attributes, like:
>> echo '* foo=one' >.gitattributes
>> echo '* foo=two' >my_dir/.gitattributes
>> where the more-specific file takes precedence. It works because we keep
>> an attribute stack, and look from most-specific directory to least.
Note that this doesn't work either:
echo '*' >.gitignore
echo '!my_dir/*' >>.gitignore
The problem isn't that git doesn't read 'my_dir/.gitignore'. Git simply doesn't
recurse into excluded directories, so patterns on excluded content have no
IMO this behavior is reasonable, as there is no way to check whether a negative
pattern will match within an excluded untracked directory without scanning the
What about this instead?
--- 8< ---
Subject: [PATCH] gitignore.txt: clarify recursive nature of excluded directories
Additionally, precedence of negated patterns is exactly as outlined in
the description, we don't need to repeat this.
Signed-off-by: Karsten Blees <bl...@dcon.de>
Documentation/gitignore.txt | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt
index f971960..a64a65d 100644
@@ -79,8 +79,9 @@ PATTERN FORMAT
- An optional prefix "`!`" which negates the pattern; any
matching file excluded by a previous pattern will become
- included again. If a negated pattern matches, this will
- override lower precedence patterns sources.
+ included again. It is not possible to re-include a file if a parent
+ directory of that file is excluded (i.e. excluding a directory
+ will recursively and irrevocably exclude the entire content).
Put a backslash ("`\`") in front of the first "`!`" for patterns
that begin with a literal "`!`", for example, "`\!important!.txt`".
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html