.gitignore Generator
About the Gitignore Generator
This gitignore generator builds a .gitignore file by combining 37 templates for languages, frameworks, game engines, operating systems, build tools and editors, from Node.js and Python to Android, iOS/Xcode, Unity, JetBrains and VS Code. Eleven of the templates are copied from the github/gitignore collection (CC0-1.0). Patterns shared by several templates are listed only once, and you can add your own rules before copying or downloading the file.
What does .gitignore do?
A .gitignore file lists path patterns that Git should not track: dependencies like node_modules/, build output like dist/, editor settings, OS clutter such as .DS_Store, and secrets such as .env. Ignored files do not show up in git status and are skipped by git add ..
It only affects untracked files. If a file was committed before you ignored it, Git keeps tracking it until you run git rm --cached <file> and commit.
Gitignore pattern syntax
Each line is one pattern. *.log matches any .log file at any depth. A trailing slash, as in build/, matches only directories. A leading slash, as in /config.json, anchors the pattern to the folder that contains the .gitignore.
** matches any number of directories, so logs/**/*.tmp covers nested folders. Lines starting with # are comments, and a leading ! re-includes something an earlier pattern excluded, for example *.log followed by !keep.log.
One catch: you cannot re-include a file if its parent directory is ignored. node_modules/ followed by !node_modules/my-patch/ does nothing; ignore node_modules/* instead and then re-include the folder.
Project, global and local ignore files
The .gitignore in your repository is shared with everyone who clones it, so keep it to project concerns. Personal noise such as editor folders or OS files can go in a global file set with git config --global core.excludesFile ~/.gitignore_global.
For rules that apply only to your clone and should never be committed, use .git/info/exclude.
Where the templates come from
Android, iOS/Xcode, Next.js, Maven, Gradle, VS Code, JetBrains, Vim, Emacs, Sublime Text and Eclipse are copied from the open-source github/gitignore collection (https://github.com/github/gitignore, CC0-1.0). Only the explanatory comments were removed; the patterns are unchanged. The iOS/Xcode template uses the upstream Objective-C.gitignore.
The other 26 templates (Node.js, Python, Go, Flutter, Unity, macOS, Windows, Terraform and so on) are hand-written or adapted by us and can differ from the upstream files, so compare them with github/gitignore if you need an exact match.
Some upstream templates rely on ! re-includes, for example VS Code ignores .vscode/* and then keeps settings.json and launch.json. A later rule for the same path overrides an earlier one, so do not combine VS Code with the older IDE Files template, which ignores the whole .vscode/ folder.
How to Use the Gitignore Generator
- Tick every stack your project uses under Select Templates (Languages, Frameworks, Game Development, OS, Tools, Editors and IDEs), or click Load example to start from a sample.
- Add project-specific rules in Custom Patterns, one per line. Use # for comments and ! to re-include a path. Patterns already emitted by an earlier template are dropped.
- Check the preview on the right, then click Copy or Download and save it as .gitignore in your repository root. Use Clear to start over.
Gitignore Generator Examples
A Go service with VS Code on Linux
Tick Go, Linux and VS Code, then add three custom lines. Your comment line is kept as written, and .env is not repeated because the Go section already contains it.
Input:
Templates: Go, Linux, VS Code Custom patterns: # local .env secrets.json
Output:
# Generated by https://dev-tools.ytools.in/tools/gitignore-generator # Go *.exe *.exe~ *.dll *.so *.dylib *.test *.out go.work .env bin/ *.cover *.prof # Linux *~ .fuse_hidden* .directory .Trash-* .nfs* # VS Code .vscode/* !.vscode/settings.json !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json !.vscode/*.code-snippets !*.code-workspace *.vsix # Custom patterns # local secrets.json
Node.js and Next.js together
Lines both templates share, such as .env, npm-debug.log* and yarn-debug.log*, appear once, in the Node.js section.
Input:
Templates: Node.js, Next.js
Output:
# Generated by https://dev-tools.ytools.in/tools/gitignore-generator # Node.js node_modules/ npm-debug.log* yarn-debug.log* yarn-error.log* .env .env.local .env.development.local .env.test.local .env.production.local dist/ build/ coverage/ .nyc_output # Next.js /node_modules /.pnp .pnp.* .yarn/* !.yarn/patches !.yarn/plugins !.yarn/releases !.yarn/versions /coverage /.next/ /out/ /build .DS_Store *.pem .pnpm-debug.log* .env*.local .vercel *.tsbuildinfo next-env.d.ts .cache .eslintcache .turbo .swc
Common Errors
- The !.vscode/settings.json lines from the VS Code template do nothing.
- You also ticked IDE Files, whose .vscode/ rule ignores the whole folder, and Git cannot re-include a file inside an ignored directory. Untick IDE Files and keep VS Code.
- A file is still tracked after you added it to .gitignore.
- Git keeps tracking files that were committed earlier. Run git rm --cached path/to/file (add -r for a folder) and commit the removal.
- The downloaded file is named gitignore without the leading dot.
- Some browsers drop the dot from downloads. Rename it to .gitignore, or use Copy and paste the text into a new .gitignore file.
- A ! rule in Custom Patterns has no effect.
- A ! rule cannot re-include something inside a directory that an earlier rule ignores as a whole, for example node_modules/ then !node_modules/my-patch/. Ignore the contents with node_modules/* instead.
Frequently Asked Questions
- Where do I put the .gitignore file?
- In the root of your repository, next to the .git folder. You can also add more .gitignore files in subfolders; their patterns are relative to that folder.
- Why is a file still tracked after I added it to .gitignore?
- Git keeps tracking files that were committed before. Run git rm --cached path/to/file (or -r for a folder), then commit the removal.
- Should package-lock.json or yarn.lock be ignored?
- No, for applications. Lockfiles make installs reproducible, so they belong in version control. None of the templates here ignore them.
- Where do the templates come from?
- Eleven of the 37 templates (Android, iOS/Xcode, Next.js, Maven, Gradle, VS Code, JetBrains, Vim, Emacs, Sublime Text and Eclipse) are copied from github/gitignore (CC0-1.0) with the comments removed. The rest are hand-written or adapted by us.
- Is my selection sent to a server?
- No. The templates are built into the page and the file is assembled in your browser.