ignore: note info/exclude lives in GIT_COMMON_DIR, not GIT_DIR

gitignore(5) says that the per-repository ignore file is $GIT_DIR/info/exclude, but in a worktree that is not the case: git rev-parse --git-path info/exclude /path/to/main/worktree/.git/info/exclude git rev-parse --git-common-dir /path/to/main/worktree/.git We actually use $GIT_COMMON_DIR/info/exclude. Adjust the documentation and some code comments to say so. Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

D. Ben Knoble committed May 12, 2026 at 17:21 UTC bd40c65bbc98eb1244d7f91e7265af0aa21e4404
6 files changed +13 -13
Documentation/git-ls-files.adoc
+1 -1
@@ -331,7 +331,7 @@ can give `--exclude-per-directory=.gitignore`, and then specify:
331 1. The file specified by the `core.excludesfile` configuration
332 variable, if exists, or the `$XDG_CONFIG_HOME/git/ignore` file.
333
334 - 2. The `$GIT_DIR/info/exclude` file.
334 + 2. The `$GIT_COMMON_DIR/info/exclude` file.
335
336 via the `--exclude-from=` option.
337
Documentation/git-svn.adoc
+1 -1
@@ -439,7 +439,7 @@ Any other arguments are passed directly to 'git log'
439 'show-ignore'::
440 Recursively finds and lists the svn:ignore and svn:global-ignores
441 properties on directories. The output is suitable for appending to
442 - the $GIT_DIR/info/exclude file.
442 + the $GIT_COMMON_DIR/info/exclude file.
443
444 'mkdirs'::
445 Attempts to recreate empty directories that core Git cannot track
Documentation/gitformat-index.adoc
+2 -2
@@ -291,14 +291,14 @@ Git index format
291 sequence in variable width encoding. Each string describes the
292 environment where the cache can be used.
293
294 - - Stat data of $GIT_DIR/info/exclude. See "Index entry" section from
294 + - Stat data of $GIT_COMMON_DIR/info/exclude. See "Index entry" section from
295 ctime field until "file size".
296
297 - Stat data of core.excludesFile
298
299 - 32-bit dir_flags (see struct dir_struct)
300
301 - - Hash of $GIT_DIR/info/exclude. A null hash means the file
301 + - Hash of $GIT_COMMON_DIR/info/exclude. A null hash means the file
302 does not exist.
303
304 - Hash of core.excludesFile. A null hash means the file does
Documentation/gitignore.adoc
+6 -6
@@ -7,7 +7,7 @@ gitignore - Specifies intentionally untracked files to ignore
7
8 SYNOPSIS
9 --------
10 -$XDG_CONFIG_HOME/git/ignore, $GIT_DIR/info/exclude, .gitignore
10 +$XDG_CONFIG_HOME/git/ignore, $GIT_COMMON_DIR/info/exclude, .gitignore
11
12 DESCRIPTION
13 -----------
@@ -34,7 +34,7 @@ precedence, the last matching pattern decides the outcome):
34 includes such `.gitignore` files in its repository, containing patterns for
35 files generated as part of the project build.
36
37 - * Patterns read from `$GIT_DIR/info/exclude`.
37 + * Patterns read from `$GIT_COMMON_DIR/info/exclude`.
38
39 * Patterns read from the file specified by the configuration
40 variable `core.excludesFile`.
@@ -50,7 +50,7 @@ be used.
50 specific to a particular repository but which do not need to be shared
51 with other related repositories (e.g., auxiliary files that live inside
52 the repository but are specific to one user's workflow) should go into
53 - the `$GIT_DIR/info/exclude` file.
53 + the `$GIT_COMMON_DIR/info/exclude` file.
54
55 * Patterns which a user wants Git to
56 ignore in all situations (e.g., backup or temporary files generated by
@@ -97,7 +97,7 @@ PATTERN FORMAT
97 match at any level below the `.gitignore` level.
98
99 - Patterns read from exclude sources that are outside the working tree,
100 - such as $GIT_DIR/info/exclude and core.excludesFile, are treated as if
100 + such as $GIT_COMMON_DIR/info/exclude and core.excludesFile, are treated as if
101 they are specified at the root of the working tree, i.e. a leading "/"
102 in such patterns anchors the match at the root of the repository.
103
@@ -146,8 +146,8 @@ CONFIGURATION
146
147 The optional configuration variable `core.excludesFile` indicates a path to a
148 file containing patterns of file names to exclude, similar to
149 -`$GIT_DIR/info/exclude`. Patterns in the exclude file are used in addition to
150 -those in `$GIT_DIR/info/exclude`.
149 +`$GIT_COMMON_DIR/info/exclude`. Patterns in the exclude file are used in
150 +addition to those in `$GIT_COMMON_DIR/info/exclude`.
151
152 NOTES
153 -----
dir.c
+2 -2
@@ -2985,7 +2985,7 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d
2985 return NULL;
2986
2987 /*
2988 - * We only support $GIT_DIR/info/exclude and core.excludesfile
2988 + * We only support $GIT_COMMON_DIR/info/exclude and core.excludesfile
2989 * as the global ignore rule files. Any other additions
2990 * (e.g. from command line) invalidate the cache. This
2991 * condition also catches running setup_standard_excludes()
@@ -3078,7 +3078,7 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d
3078 istate->cache_changed |= UNTRACKED_CHANGED;
3079 }
3080
3081 - /* Validate $GIT_DIR/info/exclude and core.excludesfile */
3081 + /* Validate $GIT_COMMON_DIR/info/exclude and core.excludesfile */
3082 root = dir->untracked->root;
3083 if (!oideq(&dir->internal.ss_info_exclude.oid,
3084 &dir->untracked->ss_info_exclude.oid)) {
dir.h
+1 -1
@@ -153,7 +153,7 @@ struct oid_stat {
153 * - The list of files and directories of the directory in question
154 * - The $GIT_DIR/index
155 * - dir_struct flags
156 - * - The content of $GIT_DIR/info/exclude
156 + * - The content of $GIT_COMMON_DIR/info/exclude
157 * - The content of core.excludesfile
158 * - The content (or the lack) of .gitignore of all parent directories
159 * from $GIT_WORK_TREE