Skip to content

[RFC PATCH] dir: add discoverable local-only .gitlocalignore#2177

Open
Msalways wants to merge 3 commits into
gitgitgadget:masterfrom
Msalways:gitlocalignore
Open

[RFC PATCH] dir: add discoverable local-only .gitlocalignore#2177
Msalways wants to merge 3 commits into
gitgitgadget:masterfrom
Msalways:gitlocalignore

Conversation

@Msalways

Copy link
Copy Markdown

This RFC proposes a new, discoverable, local-only ignore file:
.gitlocalignore, enabled via core.gitLocalIgnore.

Motivation

Many users want machine-local ignore rules (paths that exist only in
their checkout) without committing them. Today the only private option
is .git/info/exclude, which is undiscoverable: in a 2017 list thread
a contributor noted they "didn't even know .git/info/exclude existed."
.gitignore is discoverable but shared/committed, which is wrong for
local-only rules.

Design

  • A file named .gitlocalignore at the working-tree root is read only
    when core.gitLocalIgnore is true (false by default), so repositories
    that already contain such a file are not surprised.
  • It is self-excluding: .gitlocalignore is ignored by Git itself and
    never tracked or pushed.
  • Precedence: .git/info/exclude > .gitlocalignore > core.excludesFile.
  • Root-only: nested .gitlocalignore files are not read (the file is a
    single, discoverable location).

Prior art

A 2026 worktreeIgnore proposal was rejected for lacking a compelling
use case; this targets the concrete discoverability gap. Note that a
repository (0lumide/matterbridge-dummy) already ships a file named
.gitlocalignore, which is why the feature is gated behind
core.gitLocalIgnore rather than always on.

This series adds the implementation (setup_standard_excludes), tests,
and documentation.

Introduce a root-level, local-only ignore file '.gitlocalignore' that

is read only when core.gitLocalIgnore is enabled (off by default, to

avoid surprising repositories that already contain such a file).

It is self-excluding (the file itself is ignored) and ranked

below .git/info/exclude but above core.excludesFile in precedence.

This gives users a discoverable place for machine-local ignore

rules without committing them to the repository.

Signed-off-by: Shanthosh <shanthubolt@gmail.com>
@Msalways

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Jul 13, 2026

Copy link
Copy Markdown

Error: User Msalways is not yet permitted to use GitGitGadget

Msalways added 2 commits July 13, 2026 08:24
Exercise the new discoverable, local-only ignore file:

gating via core.gitLocalIgnore, self-exclusion, precedence relative

to info/exclude and core.excludesFile, root-only scoping, and that

ignored files stay out of git status and cannot be added without -f.

Signed-off-by: Shanthosh <shanthubolt@gmail.com>
Document the new root-level, local-only ignore file and its

core.gitLocalIgnore switch, including precedence and the fact that

the file is self-excluding and never tracked.

Signed-off-by: Shanthosh <shanthubolt@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant