Answer: a .gitignore is a file in your repo root listing paths Git shouldn't track — node_modules/, __pycache__/, .env, .DS_Store. This generator concatenates the official templates from github/gitignore (CC0-1.0 licensed, ~175k stars): check off what your project uses, add any custom rules, and copy or download the finished file. A Node + macOS + VS Code selection produces 217 lines of rules in two clicks.

Pick Your Templates

Languages

Operating systems

Editors & IDEs

Your .gitignore

Advertisement

What the Popular Templates Cover

TemplateLinesHeadline entries
Node143node_modules/, dist/, npm-debug.log*, .env
Python220__pycache__/, *.py[codz], .venv, .pytest_cache/
Go32*.exe, test binaries *.test, coverage files, go.work
Rust24target, debug, **/*.rs.bk, *.pdb
Java24*.class, package archives *.jar *.war, hs_err_pid*
macOS (Global)57.DS_Store, ._*, .Spotlight-V100, .Trashes
Windows (Global)24Thumbs.db, [Dd]esktop.ini, $RECYCLE.BIN/, *.lnk
VS Code (Global)11.vscode/* with re-included settings.json, launch.json, extensions.json
JetBrains (Global)87selective .idea rules: workspace.xml, shelf, dictionaries

Line counts from the live templates at github/gitignore (CC0-1.0); they shift a little as the collection is maintained.

Pattern Syntax Reference

PatternMatchesExample
node_modules/Any directory with that name, at any depthpackages/api/node_modules
/buildOnly the build folder at the repo rootbuild ✔   app/build ❌
*.logEvery file ending in .log, anywheredebug.log, a/b/error.log
docs/*.md.md files directly inside docs/docs/readme.md
docs/**/*.md.md files at any depth under docs/docs/guides/setup.md
!keep.meNegation: re-include a file an earlier pattern excluded*.log then !important.log
# commentIgnored line — templates use these as section headers# Logs

The one rule that trips everyone: negation can't rescue a file whose parent directory was excluded by an earlier pattern. Exclude files, not their folders, if you plan to re-include some.

How the Gitignore Generator Works

GitHub maintains a repository called github/gitignore — roughly 175,000 stars — containing battle-tested ignore templates for nearly every language, framework, operating system, and editor. When you create a new repository on github.com and pick a .gitignore template, that's where it comes from. The collection is released under CC0 1.0 (public domain dedication), so anyone may copy, modify, and ship the templates, which is exactly what this tool does: it fetches the templates you check straight from the jsDelivr CDN mirror of the repo and concatenates them with section headers into one file.

How to use it

Tick one box per language plus your operating system and editor, add any project-specific patterns in the custom box (environment files and secret paths are the usual suspects), and hit Generate. The result appears below with per-template headers so you can see which rules came from where. Copy it into a file named .gitignore at your repository root, or use the download button to get it ready-named.

A worked example

Take the default selection: Node, macOS, and VS Code. The three templates weigh in at 143, 57, and 11 lines respectively. Concatenated with section headers the finished file is 217 lines and about 3.3 KB: every node_modules/ folder, npm debug log, and build output directory is covered on the Node side; .DS_Store and friends on the macOS side; and the VS Code template does something clever worth stealing — it ignores .vscode/* wholesale, then re-includes the files teams genuinely share (settings.json, launch.json, extensions.json) with negation patterns. Commit that file once and the repository stays clean for every teammate on every OS.

Frequently Asked Questions

What is a .gitignore file?

It's a plain text file in your repository root listing paths Git should not track. Each line is a pattern — node_modules/, *.log, .env — and matching files stop showing up in git status and can't be committed by accident. One .gitignore at the repo root covers the whole tree; subdirectories can add their own for extra rules.

Where do I put the .gitignore file?

In the repository root, next to the .git directory. Patterns are relative to the file's location, so node_modules/ in the root ignores every node_modules folder at any depth. You can add more .gitignore files in subdirectories when one folder needs rules the rest of the repo shouldn't have.

Does .gitignore affect files already committed?

No. Git only consults .gitignore for untracked files. A file that's already in the index keeps being tracked even if you add it to .gitignore afterwards. To stop tracking it, run git rm --cached <file>, commit that removal, and then the ignore rule takes over.

What's the difference between node_modules/ and node_modules in .gitignore?

The trailing slash limits the pattern to directories, so a file literally named node_modules would still be tracked. In practice the slash is what you want almost always. A leading slash anchors the pattern to the .gitignore's directory: /build ignores only the top-level build folder, while build ignores every folder named build anywhere in the tree.

How do I ignore a file except one copy of it?

Use a negation pattern: *.log on one line, then !important.log on the next re-includes that one file. Two caveats: Git won't re-include a file if its parent directory is excluded (exclude logs/, then !logs/keep.log fails), and negations after a broad directory exclusion are the number-one source of confusing .gitignore bugs.

Can I ignore one file globally across all my repos?

Yes — that's what the global ignore file is for. Run git config --global core.excludesfile ~/.gitignore_global and put machine-specific patterns there: .DS_Store, your editor's swap files, local env files. Repository .gitignore files stay shareable with the team, while your OS cruft stays out of every repo without repeating it.

Advertisement