Gitignore Generator
Pick your stack, your editor and your operating system, and get one combined file.
Templates
4Languages
Frameworks
Tools
Editors
Operating systems
.gitignore
Node · Next.js · VS Code · macOSProcessed locally in your browser. Templates are bundled with the page. Nothing is fetched and nothing is sent.
Reference
Pattern syntax
| Pattern | Matches |
|---|---|
| build/ | A directory called build, anywhere in the tree, and everything inside it. |
| /build | Only build at the repository root — the leading slash anchors the pattern. |
| *.log | Any file ending in .log, at any depth. |
| !important.log | Un-ignores a file matched by an earlier rule. Order matters: a negation before its rule does nothing. |
| doc/**/notes | notes at any depth under doc, including directly inside it. |
One rule has no exception: a negation cannot rescue a file inside an ignored directory. Git never descends into build/ to look for !build/keep.txt. Ignore the files instead of the directory when you need that.
It only affects untracked files
Adding a pattern does not remove anything git is already tracking. If a .env is in your history, the file keeps being tracked and keeps being pushed. Untrack it with git rm --cached .env, then commit — and treat every secret that was ever committed as compromised, because it remains in the history of every clone.
Where to put which rules
Rules that describe the project — build output, dependency directories, generated files — belong in the repository's .gitignore, because everyone working on it needs them. Rules that describe your machine — .DS_Store, editor state, swap files — arguably belong in a personal global ignore file instead:
git config --global core.excludesFile ~/.gitignore_global
In practice most repositories include the operating-system and editor sections anyway, which is why they are offered here. Either choice is defensible; mixing them inconsistently across a team is what causes arguments.
Templates
Every template is written by hand and versioned. Patterns shared between two selected templates are written once, and negations are always kept in place so the rules they override still come first. Nothing is fetched at runtime — the templates ship with the page.
Questions
- Why is my file still tracked after I added it to .gitignore?
- Because .gitignore only affects untracked files. Git keeps tracking anything already in the index. Run git rm --cached <file> and commit. If it was a secret, also treat it as compromised — it remains in the history of every clone.
- Why does !important.log inside an ignored folder not work?
- Git never descends into an ignored directory, so it never sees the file to un-ignore it. Ignore the files rather than the directory — build/*.log instead of build/ — when you need an exception inside it.
- Should OS and editor rules go in the project .gitignore?
- Arguably not — .DS_Store and .idea/ describe your machine, not the project, so a global ignore file set with core.excludesFile is cleaner. In practice most repositories include them anyway. Either is defensible; being inconsistent across a team is what causes friction.