.gitignore Generator
Combine official templates, add your rules, and check any path the way git does.
1. Choose templates
312 templates from github/gitignoreTick a result to add it; Enter adds the first match.
Browse all 312 templates
Nothing selected yet. Without templates the file contains only your own rules.
One pattern per line. They come after the templates, so a ! exception here wins. To check an existing file, paste it here with no templates selected.
3. Your .gitignore
Choose templates or type rules to build the file.
4. Test paths
| Path | Result | Deciding rule |
|---|
About the .gitignore Generator
Pick the languages, frameworks, editors and operating systems your project uses and get one clean .gitignore. The rules come from github/gitignore, the collection GitHub itself offers when you create a repository: all 312 templates (languages and frameworks, Global/ editor and OS templates, and community/ stacks) are built into this page, so nothing is fetched while you work.
Repeated rules are removed without changing the result: git lets the last matching rule decide, so a duplicate is only dropped where no ! rule between the copies could make the order matter. Add your own rules at the end, then type paths into the tester to see whether git would ignore them and which line decides — the matching follows git’s own code (wildmatch and the directory rules of dir.c) and was checked against git check-ignore on more than 300 cases.
How to use it
- Search for a template (for example node, python, vscode or mac) and tick it, use the popular picks, or open Browse all templates. Each choice becomes a section of the file, in the order you pick them.
- Type project-specific rules into Your own rules, such as
.envor!.vscode/settings.json. They are added last, so they can override the templates. - Check the warnings under the file: a
!rule inside an ignored folder, a#in the middle of a line or a\used as a folder separator would silently not work. - Type paths into Test paths, one per line, ending folders with
/. Each line shows whether git would ignore it and which rule decides. - Copy the result or download it, and save it as
.gitignorein the root of your repository.
Examples
Templates: Node, macOS, VisualStudioCode Your own rules: .env.local
### Node ### # Logs logs *.log … node_modules/ … ### macOS ### # General .DS_Store … ### VisualStudioCode ### # Visual Studio Code .vscode/* !.vscode/settings.json … ### Custom rules ### .env.local
Testing node_modules/react/index.js shows *ignored by line … node_modules/ (Node)*, because a whole ignored folder takes everything inside it along.
build/ !build/keep.txt
build/* !build/keep.txt
The first version does not work: git never looks inside an ignored folder, so !build/keep.txt has no effect (the tool warns about it). Ignoring the folder’s contents with build/* lets the exception through.
Pattern cheat sheet
*.log— any file or folder ending in .log, at any depth. A pattern with no/(except at the end) matches a name anywhere./build— onlybuildat the root of the repository. A/at the start or in the middle anchors the pattern to the folder of the .gitignore.build/— only folders called build, at any depth (not a file called build).docs/*.pdf— PDFs directly inside the root docs folder;docs/**/*.pdf— at any depth inside it.**/temp— temp at any depth (the same astemp);logs/**— everything inside logs.*matches anything except/,?one character except/,[abc]and[a-z]one of a set,[!abc]anything else.!patternre-includes something an earlier rule ignored.\!and\#match a literal ! or # at the start.- Blank lines separate groups; a line starting with
#is a comment. Trailing spaces are ignored unless escaped with\.
The full rules are in the gitignore documentation.
Why a file is still tracked after you ignore it
.gitignore only affects files git does not track yet. If a file was committed before, git keeps tracking it. Stop tracking it (the file stays on disk) and commit the change:
git rm --cached path/to/file— one filegit rm -r --cached folder/— a folder
To see which rule ignores a file in your own repository, run git check-ignore -v path/to/file; it prints the file, line and pattern, like the tester on this page.
Where ignore rules can live
.gitignorein the repository (committed): rules everyone on the project needs — build output, dependencies, logs. A.gitignorein a subfolder applies to that folder, and its rules win over those of parent folders..git/info/exclude: your own rules for one repository, never committed.- A global file for every repository on your computer, set with
git config --global core.excludesFile ~/.gitignore_global(git also reads~/.config/git/ignoreby default). This is the usual place for editor and operating system files such as.DS_Store,Thumbs.dbor.idea/, so they need not be in every project.
Limitations
- The tester checks paths against this one file, as if it were the
.gitignoreat the root of the repository. Files git already tracks,.gitignorefiles in subfolders,.git/info/excludeand your global excludes file are not taken into account. - Folders are recognised by a trailing
/in the tester; git itself looks at the disk. A rule ending in/never matches a path typed without it. - Templates are a snapshot of github/gitignore. They are generic starting points: read the result, and remove rules for files your project does want to commit (for example a lock file you track).
- Matching is case-sensitive by default, as on Linux and in most CI systems. Tick Case-insensitive to see what git does with
core.ignorecase=true, the default on Windows and macOS.
Privacy
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.
Frequently asked questions
Does the order of templates matter?
Only where rules contradict each other: git applies the last matching rule, so a ! rule only re-includes what earlier rules ignored. Removing duplicates here never changes what is ignored, whatever the order. Put exceptions in Your own rules, which always come last.
How do I ignore a folder but keep one file in it?
Ignore the folder’s contents instead of the folder: logs/* and then !logs/.gitkeep. With logs/ git skips the folder entirely and cannot see the exception. For nested files, re-include each folder on the way: !logs/archive/ then logs/archive/* and !logs/archive/keep.txt.
What is the difference between /build, build/ and build?
build ignores any file or folder named build at any depth. build/ ignores only folders named build, at any depth. /build ignores only the file or folder build at the root of the repository.
Should editor and OS files go in the project’s .gitignore?
Many teams keep them out of the project and use a global excludes file instead (git config --global core.excludesFile ~/.gitignore_global), so each developer ignores their own tools. Others include the common ones (.DS_Store, .vscode/*) for safety. Both work; generate either file here.
Why does the downloaded file not start with a dot?
Some browsers and systems hide or rename files whose name starts with a dot. If the file arrives as gitignore, rename it to .gitignore (in a terminal: mv gitignore .gitignore), or copy the text into a new file in your editor.
Is anything uploaded?
No. The templates are part of the page and the file is built in your browser; your rules and test paths stay on your device.