{"thread":{"id":"65368","subject":"gitignore documentation for info/exclude files and patterns with relative directories","startedAt":"2026-03-27T11:20:56Z","lastAt":"2026-03-28T15:22:44Z","messageCount":3,"participants":["Dan Drake","Junio C Hamano","Shreyansh Paliwal"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"540175","messageId":"Qdk5yVH_yWgKl_bjCjdasusfe3PuzHCZ2rKgKIn2Xx5rcw46jmQDfA6K2vkv3V3XLSy4aqwyUlfVEmF5VlIv3EVEOlZLEnf-paw11tyhZKE=@dandrake.org","threadId":"65368","inReplyTo":null,"subject":"gitignore documentation for info/exclude files and patterns with relative directories","fromName":"Dan Drake","fromEmail":"dan@dandrake.org","sentAt":"2026-03-27T11:20:42Z","receivedAt":"2026-03-27T11:20:56Z","isPatch":false,"body":"Hello,\n\nIn the \"pattern format\" section of the gitignore manpage, it says:\n\n> The slash \"/\" is used as the directory separator. Separators may occur at the\n> beginning, middle or end of the .gitignore search pattern.\n>\n> If there is a separator at the beginning or middle (or both) of the pattern,\n> then the pattern is relative to the directory level of the particular\n> .gitignore file itself. Otherwise the pattern may also match at any\n> level below the .gitignore level.\n\nFor a .git/info/exclude file, the above makes it sound like the pattern will be \nrelative to that .git/info directory, so that you would need to use this kind of p\nattern to match files starting with 'foo' in the root of the repo:\n\n../../foo*\n\nHowever, it seems that for patterns in the info/exclude file, the beginning\nslash anchors the pattern to the root of the repo; the above pattern\nin that file should be '/foo*'.\n\nThe documentation should mention this behavior for info/exclude, as well as \nthe core.excludesFile.\n\n\n\nDan\n\n\n\n\n\n--\nCeci n'est pas une .signature.\n\n"},{"id":"540195","messageId":"xmqqwlyxkzyy.fsf@gitster.g","threadId":"65368","inReplyTo":"Qdk5yVH_yWgKl_bjCjdasusfe3PuzHCZ2rKgKIn2Xx5rcw46jmQDfA6K2vkv3V3XLSy4aqwyUlfVEmF5VlIv3EVEOlZLEnf-paw11tyhZKE=@dandrake.org","subject":"Re: gitignore documentation for info/exclude files and patterns with relative directories","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-27T16:18:45Z","receivedAt":"2026-03-27T16:18:48Z","isPatch":false,"body":"Dan Drake <dan@dandrake.org> writes:\n\n> The documentation should mention this behavior for info/exclude, as well as \n> the core.excludesFile.\n\nYup, my mistake more than 20-year-old that nobody complained so far\n;-)\n\nYes, these exclude pattern sources that are outside the working tree\nbehave as if they are specified at the root level of the working\ntree.\n\nPatches welcome. Thanks.\n"},{"id":"540278","messageId":"20260328152233.1140327-1-shreyanshpaliwalcmsmn@gmail.com","threadId":"65368","inReplyTo":"xmqqwlyxkzyy.fsf@gitster.g","subject":"[PATCH] doc: gitignore: clarify pattern base for info/exclude and core.excludesFile","fromName":"Shreyansh Paliwal","fromEmail":"shreyanshpaliwalcmsmn@gmail.com","sentAt":"2026-03-28T15:21:58Z","receivedAt":"2026-03-28T15:22:44Z","isPatch":true,"body":"The pattern format section describes how patterns are interpreted\nrelative to the location of a .gitignore file, but does not mention\nthe behavior for exclude sources outside the working tree.\n\nClarify that patterns from $GIT_DIR/info/exclude and core.excludesFile\nare treated as if they are specified at the root of the working tree,\nso a leading '/' anchors matches at the repository root.\n\nReported-by: Dan Drake <dan@dandrake.org>\nSigned-off-by: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>\n---\n Documentation/gitignore.adoc | 5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/Documentation/gitignore.adoc b/Documentation/gitignore.adoc\nindex 9fccab4ae8..a3d24e5c34 100644\n--- a/Documentation/gitignore.adoc\n+++ b/Documentation/gitignore.adoc\n@@ -96,6 +96,11 @@ PATTERN FORMAT\n    particular `.gitignore` file itself. Otherwise the pattern may also\n    match at any level below the `.gitignore` level.\n \n+ - Patterns read from exclude sources that are outside the working tree,\n+   such as $GIT_DIR/info/exclude and core.excludesFile, are treated as if\n+   they are specified at the root of the working tree, i.e. a leading \"/\"\n+   in such patterns anchors the match at the root of the repository.\n+\n  - If there is a separator at the end of the pattern then the pattern\n    will only match directories, otherwise the pattern can match both\n    files and directories.\n-- \n2.53.0\n"}]}