.gitignore Isn't the only way to ignore files in Git

464 points · 143 comments on HN · read original →

Points and comments are a snapshot, not live.

Git offers three levels of ignore files: project, local repo, and global.

The article explains three ways to ignore files in Git: `.gitignore` (shared, checked into repo), `.git/info/exclude` (per-repo but not tracked), and a global file at `~/.config/git/ignore` (machine-level per-user). It also covers using `git check-ignore -v` to diagnose which ignore file is hiding a specific file. The global file location can be customized via `git config --global core.excludesFile`.

What commenters are saying

Commenters broadly agreed the information is useful but not new, noting the official gitignore documentation covers it. Several shared practical tips: using `.git/info/exclude` for local scripts and test data, and a global ignore for editor/OS files like `.DS_Store`. A split emerged over whether to add such entries to project .gitignore (for team consistency) or rely on global excludes. One commenter warned that Git's "global" means per-user, not machine-wide.