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

Re: Git ignore help

From
Duy Nguyen <pclouds@gmail.com>
Date
Mar 24, 2015, 13:11 UTC
Message-ID
<CACsJy8CY20niCrFYq04KHxS-8xsWdGWcr_vLBvcphcSznbJzFw@mail.gmail.com>
In-Reply-To
<1PE.3lxh4.2cruo5kZ0hh.1L4LoZ@seznam.cz>
On Tue, Mar 24, 2015 at 7:46 PM,  <mdconf@seznam.cz> wrote:
Show 21 quoted lines
> Duy, you wrote:
>
> "This is true. To elaborate, if we have to recurse in excluded directories so that we can include some back, then the reason for excluding is already defeated as we may need to traverse the entire directory structure. However in this particular case where we do know in advance that only certain directories may have "re-include" rules, e.g. "db", "reports" or "scripts", we could keep going for a while."
>
> ... so according to that it sounds like including /db, /reports, /scripts should actually also NOT work. But it does work - i.e. when I add the following:
>
> # exclude
> /*
>
> # except
> !/db
> !/reports
> !/scripts
>
> then any content within those 3 directories (and their sub directories) is included and not ignored...
>
> It ONLY does not work when I add more levels - e.g.:
>
> !/reports/something
>
> In this case neither /reports nor /reports/something or any sub directory is included.

Yes. It's the subtlety of optimizing ;-) If you read the man page really carefully (*), "if the _parent_ directory of that file(**) is excluded" and the parent of these three directories is _not_ excluded.

(*) I'm not saying this is a good thing. Only docs such as language spec or RFCs need that level of attention. But I'm not a good document writer myself, can't blame others. Improvements are welcome though.

(**) "that file" should be "that file or directory" but I guess simplification here is ok

-- 
Duy
Previous: mdconf@seznam.czNext: Eric Sunshine
Message 7 of 9 in “Git ignore help”
  1. mdconf@seznam.czMar 20, 2015
  2. Eric SunshineMar 22, 2015
  3. Duy NguyenMar 24, 2015
  4. Eric SunshineMar 24, 2015
  5. Duy NguyenMar 24, 2015
  6. mdconf@seznam.czMar 24, 2015
  7. Duy NguyenMar 24, 2015
  8. Eric SunshineMar 24, 2015
  9. Junio C HamanoMar 24, 2015

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.