Windows .gitignore template
The Windows template ignores the thumbnail cache files Explorer creates in image folders, the folder customisation file, crash dumps and installer packages.
At a glance
- Category
- OS
- Patterns in this template
- 13 rules
- Directories ignored
- 1 of the 13 rules end in a slash, so they match directories only
- Also needs an OS template
- This is the OS template. Pair it with a language and an editor template.
- Typical companions
- macOS and Linux if the team is mixed. Adding all three is normal.
In detail
Thumbs.db is the thumbnail cache. Browsing a folder of images in the file manager with thumbnails enabled is enough to create it, and it holds a small preview of every image in that folder. Newer versions keep the cache centrally instead, but the file still appears on network shares and from older tooling, and a project with an assets directory is the most likely place to find one.
The variants exist for historical reasons. Thumbs.db:encryptable is an alternate data stream name that appears on encrypted volumes, and ehthumbs.db and ehthumbs_vista.db are the media centre equivalents. None of them contain anything you want in a repository, and the image previews inside them are a minor information leak of their own.
desktop.ini is the folder customisation file. It records a custom icon, a localised display name or a folder template, and it is written when someone changes a folder's appearance. The rule is written as [Dd]esktop.ini because the case varies depending on what created it and git patterns are case sensitive.
$RECYCLE.BIN is the recycle bin directory, which appears at the root of any volume including a removable drive holding a checkout. *.stackdump is a crash dump written by the Unix compatibility layer, containing the stack of the process that died.
The installer rules cover *.cab, *.msi, *.msix, *.msm and *.msp. These are packaged installers and patches, and they are build output rather than source in almost every case. *.lnk is a shortcut file, which stores an absolute path to a target on one machine and is therefore useless anywhere else.
Examples
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
*.stackdump
[Dd]esktop.ini
$RECYCLE.BIN/
*.cab
*.msi
*.msix
*.msm
*.msp
*.lnk13 lines exactly as the tool writes them, before any common additions you tick.
Things that catch people out
- The installer extensions are broad. If your repository ships a sample .msi as a test fixture, it will be ignored, and the failure only appears when someone clones fresh.
- *.lnk matches shortcut files anywhere in the tree. That is nearly always right, but it also means a deliberately committed shortcut cannot be added without forcing it.
- Thumbs.db is often already tracked in an older repository. The ignore rule does not untrack it, so run git rm --cached on it once.
Try it: .gitignore Generator
Pick one or more templates, tick the common additions you want, and copy or download the combined .gitignore.
.gitignore Generator
LOCAL · Browser-OnlyGenerate comprehensive .gitignore files by combining templates for languages, frameworks, IDEs, and operating systems
Language
Framework
IDE
OS
Build Tool
Infrastructure
Common Additions
Preview
Select templates or common additions to generate a .gitignore file.
Related .gitignore templates
All .gitignore templates →macOS .gitignore template
Where .DS_Store actually comes from, why it appears in folders nobody edited, and what the rest of the macOS template covers on network and removable volumes.
Linux .gitignore template
The shortest template in the collection. Five rules covering editor backup files, file manager settings, per volume trash and NFS silly rename files.
C# .gitignore template
Why the C# template writes [Bb]in instead of bin, what the NuGet and Visual Studio rules cover, and which per developer files it keeps out of the repository.
Gradle .gitignore template
Six rules covering the Gradle cache and build directories, with negations that keep the wrapper jar and properties tracked because a clone needs both.
Maven .gitignore template
The Maven template ignores the target directory and the backup files the release plugin leaves behind, including the wrapper jar that Gradle keeps.
npm .gitignore template
This template ignores package-lock.json, which contradicts the current advice to commit the lockfile. Here is what the rest of it covers and what to change.
Tools for this
- .gitignore Generator Generate .gitignore files for any project - 50+ templates for languages, frameworks, IDEs, and OS
- Git Commit Message Generator Free online git commit message generator - generate conventional commit messages with type, scope, and description