{"thread":{"id":"63060","subject":"[Feature Request] Negated non-wildcard patterns in excluded directories in `.gitignore`","startedAt":"2025-03-04T19:17:54Z","lastAt":"2025-03-04T19:17:54Z","messageCount":1,"participants":["Joschua Kesper"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"513565","messageId":"43b26c9b-fd08-4a21-8371-9fd53f54694a@tu-dortmund.de","threadId":"63060","inReplyTo":null,"subject":"[Feature Request] Negated non-wildcard patterns in excluded directories in `.gitignore`","fromName":"Joschua Kesper","fromEmail":"joschua.kesper@tu-dortmund.de","sentAt":"2025-03-04T19:17:46Z","receivedAt":"2025-03-04T19:17:54Z","isPatch":false,"sender":{"key":"joschua.kesper@tu-dortmund.de","avatar":null},"body":"Dear Git Community,\n\nI have the somewhat unusual use-case and use negated patterns somewhat\nregularly. If I have a path `foo/bar/baz` which I want to track with\ngit, but don't want any other files in `foo`. I would have to write the\nfollowing in the `.gitignore`:\n\n\tfoo/*\n\t!foo/bar\n\tfoo/bar/*\n\t!foo/bar/baz\n\nInstead of the simpler:\n\n\tfoo\n\t!foo/bar/baz\n\nIn `gitignore(5)` you mention:\n\n > It is not possible to re-include a file if a parent directory of that\n > file is excluded. Git doesn’t list excluded directories for\n > performance reasons, so any patterns on contained files have no\n > effect, no matter where they are defined.\n\nThis is (I think) due to patterns like `!*.c`.\nSo I propose changing it so exact-matching pattern parts like `foo` or\n`bar` to always work. This could be done by expanding it to the form\nmentioned above.\n\nThis change wouldn't affect performance I would argue, since writing\n`!foo/bar/baz` is pretty unambiguous in what the user intended.\nDepending on the implementation it may even improve performance,\nsince we would only require listing of `foo/bar/baz` and not all of it's\nparents (though I am simply guessing the implementation for\n`<something>/*` here).\n\nJoschua\n"}]}