git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Feature Request: gitignore recursion

From
Duy Nguyen <pclouds@gmail.com>
Date
Oct 7, 2013, 13:41 UTC
Message-ID
<20131007134141.GA23026@lanh>
In-Reply-To
<20131007112411.GA5792@sigill.intra.peff.net>
On Mon, Oct 07, 2013 at 07:24:11AM -0400, Jeff King wrote:
Show 14 quoted lines
> 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.
>
> ...

Yeah. I'm still bugged about that because we could at least make your case work (deep/down/.gitignore will never ever, of course) but I probably won't do anything about it for the next few months. So how about this.

The first use of footnote:[] is already in git-notes.txt. The second instance should not cause any issues with supported asciidoc versions.

-- 8< --
Subject: [PATCH] gitignore.txt: note about a behavior not so obvious much to users
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Documentation/gitignore.txt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt
index 54e334e..cd59f6e 100644
--- a/Documentation/gitignore.txt
+++ b/Documentation/gitignore.txt
@@ -21,7 +21,10 @@ Each line in a `gitignore` file specifies a pattern.
 When deciding whether to ignore a path, Git normally checks
 `gitignore` patterns from multiple sources, with the following
 order of precedence, from highest to lowest (within one level of
-precedence, the last matching pattern decides the outcome):
+precedence, the last matching pattern decides the outcome
+footnote:[Due to optimizations Git will not look further into ignored
+directories. So if you have a rule to ignore directory `foo`,
+`.gitignore` in `foo` and its subdirectories are all ignored]):
 
  * Patterns read from the command line for those commands that support
    them.
-- 
1.8.2.83.gc99314b
-- 8< --
Previous: Jeff KingNext: Karsten Blees
Message 4 of 7 in “Feature Request: gitignore recursion”
  1. AJOct 6, 2013
  2. Duy NguyenOct 7, 2013
  3. Jeff KingOct 7, 2013
  4. Duy NguyenOct 7, 2013
  5. Karsten BleesOct 10, 2013
  6. Jeff KingOct 10, 2013
  7. Karsten BleesOct 10, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.