Git development
 help / color / mirror / Atom feed
From: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, dan@dandrake.org,
	Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
Subject: [PATCH] doc: gitignore: clarify pattern base for info/exclude and core.excludesFile
Date: Sat, 28 Mar 2026 20:51:58 +0530	[thread overview]
Message-ID: <20260328152233.1140327-1-shreyanshpaliwalcmsmn@gmail.com> (raw)
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

      reply	other threads:[~2026-03-28 15:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-27 11:20 gitignore documentation for info/exclude files and patterns with relative directories Dan Drake
2026-03-27 16:18 ` Junio C Hamano
2026-03-28 15:21   ` Shreyansh Paliwal [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260328152233.1140327-1-shreyanshpaliwalcmsmn@gmail.com \
    --to=shreyanshpaliwalcmsmn@gmail.com \
    --cc=dan@dandrake.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox