.gitignore Generator
Build a .gitignore for Node, Python, Java, Go, Rust, Unity, Terraform and more, plus editor and OS files, then test real paths to see which rule ignores them.
The interactive tool loads here when JavaScript runs.
About this toolWhat is the .gitignore Generator?
Pick the languages, frameworks, tools, editors and operating systems in your project and this generator combines their ignore rules into one .gitignore. There are 38 templates, from Node.js, Python, Java with Maven or Gradle, Go, Rust, C and C++, C# and .NET, Swift and Xcode, Flutter, Ruby on Rails, Laravel, Django and Next.js to Terraform, Unity and Jupyter, plus VS Code, JetBrains IDEs, Vim, Emacs and the junk files macOS, Windows and Linux leave behind. Patterns that appear in more than one template are kept once, each section is labelled, and your own lines go at the end.
The second half of the page answers the question every .gitignore eventually raises: why is this file ignored, or why is it not? Type paths from your repository and each one is marked ignored or tracked, with the line and pattern that decided it. The matcher follows git's own rules, including anchoring, directory-only patterns, ** and negation, and it explains when a ! rule cannot work because a parent folder is already excluded.
- 38 templates for languages, frameworks, tools, IDEs and operating systems
- Based on github/gitignore (CC0), with lockfiles and examples kept
- Duplicate patterns removed across templates
- Path tester that follows gitignore(5), including the parent-directory rule
- Custom lines, copy and download as .gitignore
- Runs in your browser
How to use the .gitignore Generator
- Filter the template list or browse the groups, and click each template your project needs.
- Add any project-specific patterns in "Your own lines".
- Read the combined file on the right; duplicates have been removed and each section is labelled.
- Type paths from your repository in the test box to see which are ignored and by which line.
- Copy the file or download it as .gitignore and put it in the repository root.
Worked examples
A Next.js app on a Mac
Input
Next.js, Node.js, macOS, VS Code
Output
.next/, node_modules/, .env*.local, .DS_Store, .vscode/* with settings kept
Node.js and Next.js share several patterns; they appear once.
Negation that cannot work
Input
logs/ then !logs/keep.txt, test logs/keep.txt
Output
ignored, parent logs/ is excluded
Change the first line to logs/* so the folder is not excluded and the negation can apply.
Anchored versus floating
Input
/build, test build and src/build
Output
build ignored, src/build tracked
The leading slash ties the pattern to the repository root.
Terraform
Input
Terraform template, test prod.tfstate and .terraform.lock.hcl
Output
state ignored, lock file tracked
State files can hold secrets and belong in a remote backend; the lock file pins provider versions and should be committed.
Background and insight
Templates here are condensed from github/gitignore, the CC0-licensed collection GitHub offers when you create a repository. They keep the entries that matter for each stack (dependency folders, build output, caches, local configuration, secrets) and leave out rarely used tool files. A few choices are deliberate: lockfiles such as package-lock.json, Cargo.lock for applications and .terraform.lock.hcl are not ignored because they should be committed; .env is ignored but .env.example is kept; the VS Code template ignores .vscode/* but keeps settings.json, tasks.json, launch.json and extensions.json for sharing.
The rules come from the gitignore(5) manual. A pattern without a slash matches a name at any depth. A slash at the start or in the middle anchors the pattern to the directory of the .gitignore file, so /build matches only the top-level build. A trailing slash matches directories only. An asterisk matches anything except a slash, and two asterisks match across directories, as in **/tmp/ or docs/**/*.pdf. A leading ! re-includes something an earlier pattern excluded, and the last matching pattern wins.
One rule defeats many negations: git does not look inside a directory it has excluded, so "It is not possible to re-include a file if a parent directory of that file is excluded." logs/ followed by !logs/keep.txt does not work; logs/* followed by !logs/keep.txt does, because the folder itself is not excluded. And .gitignore only affects untracked files. A file already committed stays tracked until you run git rm --cached on it.
Common use cases
Starting a repository
Create a sensible .gitignore before the first commit so build output and secrets never enter history.
Mixed-language monorepos
Combine Python, Node and Terraform rules without copy-pasting three files together.
Fixing a .gitignore that misbehaves
Test the paths in question to see which rule matches and why a negation is ignored.
Team editor settings
Ignore personal IDE state while keeping shared VS Code settings and launch configurations in the repository.
Tips and limitations
- Commit lockfiles for applications. They make installs reproducible and are not build output.
- Put personal editor and OS patterns in a global excludes file (git config --global core.excludesFile) so every repository benefits.
- If a secret was ever committed, ignoring it now is not enough: rotate the secret, then remove it from history.
- Run git check-ignore -v <path> to confirm which rule matches on your machine.
- Use git rm -r --cached <path> once, then commit, to stop tracking something that is now ignored.
Frequently asked questions
Why is git still tracking a file I added to .gitignore?
.gitignore only applies to untracked files. If the file was committed before, run git rm --cached <file> (or -r for a folder), commit, and from then on it stays ignored. The file remains on disk.
Why does my ! negation pattern not work?
Most often a parent directory is excluded. Git does not look inside excluded directories, so a file in them cannot be re-included. Exclude the contents (folder/*) instead of the folder (folder/), then add the ! rule.
Should package-lock.json or yarn.lock be in .gitignore?
No, commit them for applications. Lockfiles record the exact dependency versions so every install and CI run gets the same tree. The templates here do not ignore them.
What does a leading slash mean in a .gitignore pattern?
It anchors the pattern to the directory containing the .gitignore. /build matches build at the repository root but not src/build. A slash in the middle of a pattern, as in docs/*.pdf, anchors it too.
How do I ignore .DS_Store in every repository?
Add .DS_Store to a global ignore file and register it with git config --global core.excludesFile ~/.gitignore_global. Adding it to each project's .gitignore also works and helps teammates.
What is the difference between * and ** in .gitignore?
A single * matches any characters except a slash, so it stays within one directory level. ** matches across directories: **/tmp matches tmp anywhere, and a/**/b matches a/b, a/x/b and a/x/y/b.
Is there an in-depth guide to the .gitignore Generator?
Yes. “.gitignore Patterns Explained: Rules, Negation and What to Ignore” covers the background, how it works, common pitfalls and worked examples. Read the full guide.
People also search for
- gitignore template for node and react
- python gitignore venv pycache
- gitignore not ignoring file already committed
- how to ignore ds_store in git
- gitignore negation not working in folder
- should package-lock.json be in gitignore
- terraform gitignore tfstate lock file
- gitignore vscode folder but keep settings.json
Related Tools You May Like
Free, in-browser tools that pair well with this one.