
TL;DR
Most developers only know .gitignore, but Git offers two other ignore mechanisms for local workflows and machine-wide patterns. Here's when to use each.
A post on Hacker News today resurfaced something that many developers overlook: .gitignore is not the only way to ignore files in Git. There are actually three distinct mechanisms, each designed for different use cases. Understanding when to use which can clean up your repos and avoid awkward pull request feedback.
The familiar option. Whatever patterns you add to .gitignore get committed to the repository and apply to everyone who clones it.
# .gitignore
node_modules/
dist/
.env
Use for: Build artifacts, dependencies, environment files - anything project-specific that no contributor should commit.
Located inside the .git directory, this file follows the same syntax as .gitignore but never gets committed. It's repository-specific and stays on your machine only.
# .git/info/exclude
my-local-notes.md
scratch/
debug.log
Use for: Personal scratch files, local test data, IDE configs that only you use, Makefiles or scripts specific to your dev environment.
A global ignore file that applies across every repository on your system. By default, Git looks for it at ~/.config/git/ignore, but you can point it elsewhere:
git config --global core.excludesFile ~/.gitignore_global
# ~/.config/git/ignore
.DS_Store
Thumbs.db
*.swp
.idea/
Use for: OS-specific cruft like .DS_Store on macOS or Thumbs.db on Windows. Also useful for editor-specific files you use across all projects.
Get the weekly deep dive
Tutorials on Claude Code, AI agents, and dev tools - delivered free every week.
From the archive
Jun 19, 2026 • 8 min read
Jun 19, 2026 • 8 min read
Jun 18, 2026 • 6 min read
Jun 18, 2026 • 7 min read
When a file is being ignored and you're not sure why, Git has a built-in diagnostic:
git check-ignore -v myfile.txt
This outputs the file path, line number, and pattern responsible for ignoring the file. It's invaluable when you inherit a repo with complex ignore rules or when you're troubleshooting why something isn't showing up in git status.
The Hacker News discussion (439 points, 137 comments) surfaced some practical patterns from experienced developers:
The "attic" pattern. Several commenters add attic to their global ignore, then create an attic/ directory in any project for random files that should never be committed. One commenter takes this further by putting a .gitignore inside the attic/ directory containing just * - making the directory self-ignoring.
The scope debate. There's a split on whether IDE/editor-specific ignores belong in the repo's .gitignore or your personal global config. The pragmatic argument: adding .idea/ or .vscode/ to every project's .gitignore saves everyone the trouble of configuring their global ignore. The purist argument: a repo's .gitignore should only contain patterns relevant to the project itself.
Devcontainer edge case. One commenter pointed out that global ignore files don't survive devcontainer rebuilds - you need to bind-mount your config or explicitly persist it.
The Magit angle. Emacs users noted that Magit has native support for choosing between shared (.gitignore) and private (.git/info/exclude) ignores when pressing i on a file.
Here's when to use each:
| Scenario | Use |
|---|---|
| Build output, dependencies, secrets | .gitignore |
| Personal scratch files in one repo | .git/info/exclude |
| OS/editor files across all repos | ~/.config/git/ignore |
The key insight: if it's something every contributor would need to ignore, put it in .gitignore. If it's specific to your workflow but not the project, use the local or global options.
Bloated .gitignore files are a code smell. When a repo's ignore file contains 50 lines covering every IDE, editor, and OS under the sun, it suggests nobody is using the right tool for the job. The result is a file that's hard to maintain and hides project-specific patterns in noise.
Knowing about .git/info/exclude and the global ignore file gives you cleaner repos and fewer "please remove your IDE config from the gitignore" code review comments.
Read next
Epic Games open-sourced Lore, a centralized version control system designed for binary-heavy game projects. It uses Merkle trees, on-demand file hydration, and native chunked storage to handle terabyte-scale repos that Git struggles with.
7 min readAuto-installing tree-sitter grammars, built-in markdown mode, window layout commands, and more - the upcoming Emacs release absorbs features that used to require external packages.
6 min readThe IETF published RFC 10008 defining a new HTTP QUERY method - GET with a request body. It is safe, idempotent, cacheable, and solves the longstanding problem of complex queries hitting URL length limits.
6 min readTechnical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
OpenAI's coding agent for terminal, cloud, IDE, GitHub, Slack, and Linear workflows. Reads repos, edits files, runs comm...
View ToolMost popular LLM framework. 100K+ GitHub stars. Chains, RAG, vector stores, tool use. LangGraph adds stateful multi-agen...
View ToolPrivate local AI chatbot by Nomic. 250K+ monthly users, 65K GitHub stars. LocalDocs feature lets you chat with your own...
View ToolGive your agents a filesystem that branches like git. Crash-safe by default.
View AppCatch broken SKILL.md files in CI before they hit your team.
View AppReplay every MCP tool call to find why your agent went sideways.
View AppFull GitHub CLI support for automated PR and issue workflows.
Claude CodeReusable markdown files with instructions and workflows.
Claude CodeConfigure Claude Code for maximum productivity -- CLAUDE.md, sub-agents, MCP servers, and autonomous workflows.
AI Agents
Auto-installing tree-sitter grammars, built-in markdown mode, window layout commands, and more - the upcoming Emacs rele...

Epic Games open-sourced Lore, a centralized version control system designed for binary-heavy game projects. It uses Merk...

The IETF published RFC 10008 defining a new HTTP QUERY method - GET with a request body. It is safe, idempotent, cacheab...

Java's most anticipated performance feature is finally landing. Value classes eliminate object identity overhead and ena...

A YC W25 startup open-sources CADAM, a browser-based tool that converts natural language to parametric OpenSCAD models....

Alex Ellis shares real production experience running local LLMs: $12k hardware investment, 2-3 month ROI, and why treati...

New tutorials, open-source projects, and deep dives on coding agents - delivered weekly.