What Gitignore Generator does
This gitignore generator builds a .gitignore from twelve short, fixed sections: Node, Python, Java, Go, Rust, PHP, VS Code, JetBrains, macOS, Windows, Linux and environment files. Each ticked box adds its patterns under a comment heading, so the default selection of Node, VS Code, macOS and env files gives 29 patterns in 4 sections, and ticking everything gives 77 in 12. The sections are deliberately small, covering dependency folders, build output, caches, editor settings, operating system clutter and secrets, so the file stays readable. The full contents of every section are listed below, which lets you see what you are getting before you commit it.
Every pattern in each gitignore template
The Patterns column matches the count the tool reports when only that box is ticked.
| Checkbox | Patterns | Lines added |
|---|---|---|
| Node / JavaScript | 13 | node_modules/, npm-debug.log*, yarn-debug.log*, yarn-error.log*, pnpm-debug.log*, .pnpm-store/, dist/, build/, .next/, .nuxt/, .cache/, coverage/, *.tsbuildinfo |
| Python | 14 | __pycache__/, *.py[cod], *.egg-info/, .eggs/, build/, dist/, .venv/, venv/, env/, .pytest_cache/, .mypy_cache/, .ruff_cache/, .coverage, htmlcov/ |
| Java / Gradle / Maven | 8 | *.class, *.jar, *.war, *.ear, target/, build/, .gradle/, hs_err_pid* |
| Go | 6 | *.exe, *.test, *.out, bin/, vendor/, go.work.sum |
| Rust | 3 | target/, **/*.rs.bk, and a Cargo.lock line with a note (see the list of things to adjust) |
| PHP / Composer | 3 | /vendor/, composer.phar, .phpunit.result.cache |
| VS Code | 4 | .vscode/*, !.vscode/settings.json, !.vscode/extensions.json, *.code-workspace |
| JetBrains IDEs | 4 | .idea/, *.iml, *.iws, out/ |
| macOS | 6 | .DS_Store, .AppleDouble, .LSOverride, ._*, .Spotlight-V100, .Trashes |
| Windows | 5 | Thumbs.db, ehthumbs.db, Desktop.ini, $RECYCLE.BIN/, *.lnk |
| Linux | 5 | *~, .fuse_hidden*, .directory, .Trash-*, .nfs* |
| Env files & secrets | 6 | .env, .env.local, .env.*.local, *.pem, *.key, secrets.json |
Sections are written in this order, each under a comment such as # Node. The file starts with a one-line comment naming the generator, which you can delete.
Gitignore file sizes for common project setups
Boxes ticked, and the Sections and Patterns figures shown in the Summary.
JavaScript or TypeScript app on a Mac (the default)
Node / JavaScript, VS Code, macOS, Env files & secrets
4 sections, 29 patterns
Python project in VS Code
Python, VS Code, macOS, Env files & secrets
4 sections, 30 patterns
Node front end with a Python back end
Node / JavaScript, Python, VS Code, macOS, Env files & secrets
5 sections, 43 patterns
build/ and dist/ appear in both the Node and the Python section. Repeated lines are harmless to Git.
Java service built in IntelliJ on Windows
Java / Gradle / Maven, JetBrains IDEs, Windows
3 sections, 17 patterns
Team on mixed operating systems
Node / JavaScript, VS Code, macOS, Windows, Linux, Env files & secrets
6 sections, 39 patterns
Lines to review after generating
The sections are general starting points. These are the patterns most likely to need a change for your project.
- Rust, Cargo.lock: the generated line is Cargo.lock followed by two spaces and a note beginning with #. Git only treats # as a comment at the start of a line, so as written this line matches nothing and Cargo.lock is not ignored. For an application, delete the line. For a library where you do want the lock file ignored, delete the note so the line reads Cargo.lock.
- Java, *.jar: this also matches gradle/wrapper/gradle-wrapper.jar, which Gradle projects are meant to commit. Add !gradle/wrapper/gradle-wrapper.jar on a new line below the Java section.
- Go, vendor/ and bin/: remove vendor/ if the project commits its vendored dependencies.
- Node and Python, build/ and dist/: these match a folder with that name at any depth. If you keep source in a folder called build, anchor or remove the rule.
- Env files: .env, .env.local and names such as .env.production.local are ignored, but .env.production and .env.development are not. Add .env.* followed by !.env.example if those files hold secrets too.
- Env files, *.key and *.pem: any file with these extensions is ignored anywhere in the tree, including public test fixtures. Re-include specific files with a ! rule if needed.
- VS Code: everything in .vscode is ignored except settings.json and extensions.json. Add !.vscode/launch.json or !.vscode/tasks.json if the team shares those.
- Duplicates across sections, such as target/ in both Java and Rust, are not merged. They do no harm.
Gitignore pattern syntax
| Pattern | What it matches |
|---|---|
| build | Any file or folder named build, at any depth |
| build/ | Folders named build only, at any depth, with everything inside |
| /build | Only the build file or folder next to this .gitignore |
| *.log | Every file ending in .log, in any folder |
| *.py[cod] | Files ending in .pyc, .pyo or .pyd |
| **/*.rs.bk | Files ending in .rs.bk in any folder; ** matches any number of folder levels |
| docs/*.pdf | PDF files directly inside docs, not in its subfolders |
| !keep.log | Re-includes keep.log after an earlier rule ignored it |
| # text | A comment, when # is the first character of the line |
| \#notes | A file literally named #notes; the backslash escapes the # |
A file cannot be re-included with ! if its parent folder is ignored, because Git does not look inside ignored folders. That is why the VS Code section ignores .vscode/* and not .vscode/.
Removing files that were committed before the .gitignore existed
Adding a pattern does not untrack anything. If node_modules or a build folder is already in the repository, run git rm -r --cached node_modules and commit. The --cached flag removes the folder from Git's index and leaves the copy on your disk alone. From then on the ignore rule keeps it out.
This fixes future commits only. Every earlier commit still contains the files, and anyone who clones the repository receives that history. For large folders that is merely wasted space. For a password or key it is a leak: treat the credential as exposed, replace it, and if the history must be cleaned use a rewriting tool such as git filter-repo.
To find out why a particular path is or is not ignored, run git check-ignore -v followed by the path. Git prints the file, line number and pattern responsible, which is quicker than reading the whole file.
Step by step
- 1
Tick each language your repository uses: Node / JavaScript, Python, Java / Gradle / Maven, Go, Rust or PHP / Composer. Several can be ticked at once.
- 2
Tick the editors people on the project use: VS Code, JetBrains IDEs, or both.
- 3
Tick the operating systems contributors work on: macOS, Windows and Linux.
- 4
Leave Env files & secrets ticked unless the repository has no local configuration at all. At least one box must be ticked for a file to be produced.
- 5
Copy the text under .gitignore or download the file, save it in the repository root next to the .git folder, and commit it.