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

Re: git 2.34.0: Behavior of `**` in gitignore is different from previous versions.

From
DADanial Alihosseini <danial.alihosseini@gmail.com>
Date
Nov 19, 2021, 17:06 UTC
Message-ID
<CACLOEFb41ZLvvkaF6xivFShOJfSHcNupzstiShKHiNCg4DCEhQ@mail.gmail.com>
In-Reply-To
<72fffbff-16f7-fa17-b212-67aae9e1b034@gmail.com>
Thanks Derrick.
Show 6 quoted lines
> 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

Previous: Derrick StoleeNext: Johannes Sixt
Message 6 of 13 in “git 2.34.0: Behavior of `**` in gitignore is different from previous versions.”
  1. Danial AlihosseiniNov 18, 2021
  2. Jeff KingNov 18, 2021
  3. Derrick StoleeNov 18, 2021
  4. Danial AlihosseiniNov 19, 2021
  5. Derrick StoleeNov 19, 2021
  6. Danial AlihosseiniNov 19, 2021
  7. Johannes SixtNov 19, 2021
  8. Derrick StoleeNov 19, 2021
  9. Ævar Arnfjörð BjarmasonNov 19, 2021
  10. Chris TorekNov 20, 2021
  11. Junio C HamanoNov 21, 2021
  12. Philip OakleyNov 23, 2021
  13. Danial AlihosseiniNov 23, 2021

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.