]> git.ipfire.org Git - thirdparty/git.git/commitdiff
doc: gitignore: clarify pattern base for info/exclude and core.excludesFile
authorShreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
Sat, 28 Mar 2026 15:21:58 +0000 (20:51 +0530)
committerJunio C Hamano <gitster@pobox.com>
Sat, 28 Mar 2026 18:41:59 +0000 (11:41 -0700)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/gitignore.adoc

index 9fccab4ae8df2325d728d4876ef50822bf4b656a..a3d24e5c34aabc1b2f2776b77296768ef6da1c22 100644 (file)
@@ -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.