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

[PATCH] doc: gitignore: clarify pattern base for info/exclude and core.excludesFile

From
Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
Date
Mar 28, 2026, 15:21 UTC
Message-ID
<20260328152233.1140327-1-shreyanshpaliwalcmsmn@gmail.com>
In-Reply-To
<xmqqwlyxkzyy.fsf@gitster.g>

The pattern format section describes how patterns are interpreted relative to the location of a .gitignore file, but does not mention the behavior for exclude sources outside the working tree.

Clarify that patterns from $GIT_DIR/info/exclude and core.excludesFile are treated as if they are specified at the root of the working tree, so a leading '/' anchors matches at the repository root.

Reported-by: Dan Drake <dan@dandrake.org>
Signed-off-by: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
---
 Documentation/gitignore.adoc | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/Documentation/gitignore.adoc b/Documentation/gitignore.adoc
index 9fccab4ae8..a3d24e5c34 100644
--- a/Documentation/gitignore.adoc
+++ b/Documentation/gitignore.adoc
@@ -96,6 +96,11 @@ PATTERN FORMAT
    particular `.gitignore` file itself. Otherwise the pattern may also
    match at any level below the `.gitignore` level.
 
+ - Patterns read from exclude sources that are outside the working tree,
+   such as $GIT_DIR/info/exclude and core.excludesFile, are treated as if
+   they are specified at the root of the working tree, i.e. a leading "/"
+   in such patterns anchors the match at the root of the repository.
+
  - If there is a separator at the end of the pattern then the pattern
    will only match directories, otherwise the pattern can match both
    files and directories.
-- 
2.53.0
Previous: Junio C Hamano
Message 3 of 3 in “gitignore documentation for info/exclude files and patterns with relative directories”
  1. Dan DrakeMar 27, 2026
  2. Junio C HamanoMar 27, 2026
  3. doc: gitignore: clarify pattern base for info/exclude and core.excludesFileShreyansh Paliwal, Mar 28, 2026

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.