This explains how Git reads ignore patterns from three places and why the lesser-known ones are useful. One is the familiar .gitignore, committed and shared with everyone; the second is .git/info/exclude, which lives inside .git so it affects only that clone and cannot be accidentally committed; the third is a machine-wide file (default ~/.config/git/ignore or whatever core.excludesFile points to) that applies to every repo on that machine. All three use the same pattern syntax and, importantly, ignore rules never hide files that are already tracked. The per-repo exclude is ideal for private scratch files (notes, agent plans, editor clutter) that you don’t want pushed or visible to collaborators.
Practical details include simple ways to append patterns (e.g., echo 'plans/' >> .git/info/exclude or echo '.DS_Store' >> ~/.config/git/ignore) and a worktree caveat: when .git is a file, update the right exclude via "$(git rev-parse --git-common-dir)/info/exclude". Git reads the global file automatically if present, or you can set git config --global core.excludesFile to point elsewhere. A final note: some tools (example provided) omit ignored files from file-autocomplete by default; toggle that behavior with a setting (respectGitignore: false) if you still want ignored files surfaced.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.