.gitignore Generator
A gitignore generator builds a ready-to-use .gitignore file for your stack, so build artifacts, dependencies, and secrets never get committed. Check the boxes for the technologies your project uses — Node, Python, Laravel, WordPress, editors, operating systems — and the rules merge into one clean file with duplicates removed. The guide below covers pattern syntax, negation rules, and what to do when Git keeps tracking files you thought you ignored.
The 12 templates
The generator offers twelve hand-maintained templates — check every one your project touches:
| Template | Ignores things like |
|---|---|
| Node (checked by default) | node_modules/, build output, logs |
| PHP | vendor/, Composer artifacts |
| Laravel | Storage, cache, compiled views, .env |
| WordPress | Uploads, cache plugins, local config |
| Python | __pycache__/, virtualenvs, *.pyc |
| React / Vite | dist/, build output, local env files |
| Environment files | .env, .env.local and variants |
| macOS | .DS_Store, AppleDouble files |
| Windows | Thumbs.db, Desktop.ini |
| VS Code | .vscode/ workspace settings |
| JetBrains (PhpStorm/WebStorm) | .idea/ project files |
| Logs & temp files | *.log, temp files, backups |
Each selected template becomes a commented section in the output (e.g. # Node), and exact duplicate lines across templates are removed automatically.
Gitignore pattern syntax
A .gitignore file is a list of patterns, one per line. Blank lines are ignored and lines starting with # are comments. These are the patterns you'll use most:
| Pattern | What it ignores |
|---|---|
*.log | All files ending in .log, in any directory |
build/ | The build directory and everything inside it (trailing slash = directories only) |
/dist | Only the dist path at the .gitignore's own level (a leading slash anchors the pattern) |
**/temp | Any directory named temp at any depth |
file?.txt | file1.txt, fileA.txt — ? matches exactly one character |
!keep.log | Re-includes keep.log after a broader rule ignored it (negation) |
Patterns are checked top to bottom, and the last matching pattern wins — which is what makes negation possible.
How to use it
- Check every box that applies to your project — stack, framework, editor, and OS (Node is checked by default).
- Review the merged output, which updates live with one commented section per template and duplicates removed.
- Copy the output, or download it directly as
.gitignore. - Place the file in your project's root folder, next to
.git, and commit it.
How it works
Each option maps to a fixed, hand-maintained list of common ignore patterns for that ecosystem. Selecting several options merges their lists and removes exact duplicate lines, keeping the file readable.
Limitations
These are common, general-purpose patterns — not a live copy of GitHub's official template collection, so highly project-specific build paths may need adding by hand.
Negation: un-ignoring files with !
Prefix a pattern with ! to re-include files that an earlier rule ignored. This is useful when you ignore a whole category but need one exception:
# Ignore all PDFs, except the spec the team reviews
*.pdf
!spec.pdf
One gotcha: you cannot re-include a file inside an excluded directory. Git never looks inside directories it has excluded, so this does not work:
build/
!build/keep.txt # no effect — Git skips build/ entirely
Instead, ignore the directory's contents while keeping the directory itself visible to Git:
build/*
!build/keep.txt
Git still tracking files you ignored?
.gitignore only applies to untracked files. If a file was committed before you added its pattern, Git keeps tracking it. Stop tracking without deleting your local copy:
git rm --cached <file> # stop tracking one file
git rm -r --cached . # stop tracking everything, then re-add
git add .
git commit -m "Apply .gitignore"
Never commit secrets. Add .env to your .gitignore on day one and commit a .env.example with placeholder values instead. Removing a leaked secret from history means rewriting every commit that touched it — prevention is the only sane option.
Frequently asked questions
- Can I combine multiple stacks, like PHP and Node?
- Yes — check every option that applies to your project (for example Laravel, Node, and VS Code together) and the rules are merged into one file with duplicates removed.
- I already have a .gitignore. Can I add to it?
- Yes — copy the parts you need from the output and append them to your existing file, then remove any duplicate lines.
- Why is my .env file listed?
- Environment files usually hold secrets like API keys and database passwords, so most stack presets exclude them by default. Double-check this matches your project's setup before committing.
- What if I've already committed a file I now want ignored?
- Adding it to .gitignore only stops new changes from being tracked. For a file already committed, run `git rm --cached <file>` first, then commit that removal.
- Can I merge gitignore templates for multiple stacks?
- Yes — that is exactly what the generator above does. Select one template per technology (for example, Python for the backend, React / Vite for the frontend, plus macOS for OS files) and it merges them into a single file with duplicates removed. For monorepos with several packages, consider a root .gitignore for shared rules plus per-package files for stack-specific ones.
- Where should the .gitignore file go?
- Put it in your repository root so it covers the whole project, and commit it — ignore rules are part of the project, not personal preference. You can also add .gitignore files in subdirectories; their patterns apply to everything below them. For personal files no repo should ever see, use a global ignore file via git config --global core.excludesFile ~/.gitignore_global.
- Should I commit my .env file?
- No — never. .env files hold API keys, database passwords, and other secrets, and anything committed to Git is effectively permanent; even deleting the file later leaves it in history. Add .env to .gitignore on day one and commit a .env.example containing only placeholder keys and comments, so teammates know which variables to set without seeing your values.