guides

.gitignore guides

From pattern syntax to precedence, global configuration, untracking committed files and debugging — based on the official git documentation.

The Complete Guide to .gitignore Pattern Syntax

gitignore pattern syntax with example tables: comments, escaping and trailing spaces, negation with !, trailing slashes, anchoring, the *, ? and [] wildcards, and ** rules.

gitignore Precedence and Negation (!) Patterns

How the last matching rule wins, the precedence between .gitignore, info/exclude and global settings, and why ! cannot restore files when a parent directory is excluded, with fixes.

Setting Up a Global gitignore (core.excludesFile)

How to set core.excludesFile so that files from your personal environment, such as macOS .DS_Store and editor files, are ignored in every repository, and what the default path is.

Writing Your Own Ignore Rules with .git/info/exclude

How to write personal ignore rules that apply to a single repository in .git/info/exclude without editing .gitignore, when it is useful, and where it sits in precedence.

Ignoring Files That Are Already Committed

How to stop tracking files that remain tracked after being added to .gitignore with git rm --cached, how to find tracked files matched by ignore rules, and what to do first when secrets were committed.

Why Is It Ignored? Debugging with git check-ignore

How to find which rule ignores a file with git check-ignore -v, git status --ignored and git ls-files, and a checklist of 7 common reasons a rule does not work.

What to Ignore and What to Commit

Guidelines for ignoring build output, dependencies, caches and secrets while committing lockfiles, example configs and team editor settings, plus nested .gitignore files, keeping empty directories and merging templates.