Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
Git

Git: Fix a .git/info/exclude Rule That Silently Only Hides Files for You Because It Was Never Meant to Be Shared With Teammates

- 22.10.26 - ErcanOPAK

🔀 The Ignore Rule That Only Ever Lived on One Machine

.git/info/exclude works exactly like a .gitignore file in every practical sense – same pattern syntax, same effect on git status and git add – with exactly one deliberate difference: it lives inside the .git directory itself rather than in the repository’s tracked working tree, specifically so its rules apply only to the one local clone they were written in and are never committed, pushed, or seen by anyone else who clones the same repository. A developer who adds a pattern there expecting it to behave like a project-wide .gitignore entry – say, to silence a personal editor’s config file or a locally generated report – gets exactly the local-only behavior the mechanism was designed for, then is confused weeks later when a teammate’s fresh clone shows that same file as untracked and cluttering git status, with no .gitignore entry anywhere in the repository history explaining why.

🔎 The Problem

$ cat .git/info/exclude
# Local notes and scratch files I don't want cluttering git status
*.local-notes.md
/reports/draft-*.csv

$ git status
nothing to commit, working tree clean    <- clean, on THIS machine

# .git/info/exclude lives inside .git/ itself, which is never
# tracked, committed, or transferred by clone/push/pull in any way -
# it is pure per-clone local configuration, by design.

# A teammate clones the same repository fresh:
$ git status
Untracked files:
  draft-notes.local-notes.md
  reports/draft-march.csv

# Nothing in the committed .gitignore (if one even exists) mentions
# these patterns, because they were never meant to be shared -
# the teammate has no way to discover these exclusion rules exist
# at all without being told directly.

✅ Fix: Use info/exclude Only for Genuinely Personal, Local-Only Rules

  • Reserve .git/info/exclude strictly for patterns that are genuinely personal to one developer’s own local setup – a particular editor’s scratch files, a personally generated report format nobody else produces – and move anything that should apply consistently for every clone of the repository into the project’s tracked .gitignore file instead.
  • If a rule was added to info/exclude by habit rather than deliberate choice, check whether it actually belongs in the committed .gitignore – most build artifacts, dependency folders, and generated files that any contributor’s machine would also produce are exactly the case .gitignore exists for, and info/exclude being local-only is actively the wrong behavior for them.
  • Document any genuinely personal info/exclude patterns somewhere a new team member would actually see them (a CONTRIBUTING.md note mentioning the convention, for instance) if the pattern represents a recurring local-tooling artifact every new contributor is likely to hit – the mechanism’s local-only nature means the only other way teammates learn about it is by noticing the clutter themselves and asking.

🚨 Why This Is Dangerous

  • There is no git command that lists or surfaces info/exclude’s rules to anyone who isn’t already looking directly inside .git/info/exclude on that exact machine – a teammate confused by untracked files has no obvious command to run that would reveal a colleague elsewhere has a local rule hiding the equivalent file on their own clone.
  • Because info/exclude’s effect is completely invisible in any commit, pull request, or code review – it never appears in diffs, since .git/ itself is never tracked – two developers working on the same repository can have meaningfully different git status output for the same working tree state indefinitely, with neither having any way to notice the discrepancy from the tracked history alone.

A .gitignore rule is a decision the whole team made together, visible in history forever. The same pattern in info/exclude is a decision exactly one person made, visible to exactly that one person, forever.

— Version Control Tip

Related posts:

Git: Recover a Commit You Accidentally Amended Over the Wrong Change

Git: Recover a Commit You Accidentally Amended Over the Wrong Change

Git: Fix git fetch --all Not Actually Updating a Remote Branch Because a Second Remote With the Same...

Git: Fix git fetch --all Not Actually Updating a Remote Branch Because a Second Remote With the Same...

Git: Fix git worktree list Still Showing a Worktree You Already Deleted by Hand From Disk

Git: Fix git worktree list Still Showing a Worktree You Already Deleted by Hand From Disk

Views: 4

Post navigation

C#: Fix a Task.Delay Call Inside a Retry Loop That Never Actually Delays Because the Returned Task Was Never Awaited
C#: Fix an IComparer Implementation That Violates Transitivity and Makes Sort Throw or Silently Produce Wrong Order Depending on Input Size

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

November 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« Oct    

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,055)
  • Get the User Name and Domain Name from an Email Address in SQL (981)
  • How to add default value for Entity Framework migrations for DateTime and Bool (977)
  • Get the First and Last Word from a String or Sentence in SQL (858)
  • How to select distinct rows in a datatable in C# (854)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (653)
  • Add Constraint to SQL Table to ensure email contains @ (609)
  • Average of all values in a column that are not zero in SQL (570)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (547)
  • Find numbers with more than two decimal places in SQL (475)

Recent Posts

  • C#: Fix a ConditionalWeakTable Entry Vanishing Too Soon
  • Docker: Fix a Stale COPY Layer After Editing .dockerignore
  • Photoshop: Fix a Pattern Overlay Scaling Wrong on a High-DPI File
  • SQL Server: Fix a Computed Column Index Skipped by Implicit Cast
  • HTML5: Fix a required Input Inside a Hidden Tab Blocking Submit
  • SQL Server: Fix ROW_NUMBER Ties Reordering Between Identical Runs
  • C#: Fix an Enum HasFlag Returning True for the Zero Value
  • WordPress: Fix Featured Images Vanishing After a CDN Migration
  • Photoshop: Fix Content-Aware Fill Smearing a Repeating Pattern
  • Asp.Net Core: Fix Antiforgery Tokens Rejected Behind a Reverse Proxy

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,055)
  • Get the User Name and Domain Name from an Email Address in SQL (981)
  • How to add default value for Entity Framework migrations for DateTime and Bool (977)
  • Get the First and Last Word from a String or Sentence in SQL (858)
  • How to select distinct rows in a datatable in C# (854)

Recent Posts

  • C#: Fix a ConditionalWeakTable Entry Vanishing Too Soon
  • Docker: Fix a Stale COPY Layer After Editing .dockerignore
  • Photoshop: Fix a Pattern Overlay Scaling Wrong on a High-DPI File
  • SQL Server: Fix a Computed Column Index Skipped by Implicit Cast
  • HTML5: Fix a required Input Inside a Hidden Tab Blocking Submit

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com