Unity .gitignore template
The Unity template ignores the asset import cache, temporary build directories and every generated IDE project file, all written with case tolerant bracket patterns.
At a glance
- Category
- Framework
- Patterns in this template
- 30 rules
- Directories ignored
- 11 of the 30 rules end in a slash, so they match directories only
- Also needs an OS template
- Yes, and it matters here: asset folders accumulate file manager metadata files.
- Typical companions
- An IDE template plus an OS template. C# is largely covered by these rules already.
In detail
Library is the asset import cache and the single largest directory in a project. Every texture, model and audio file gets converted into an internal representation the first time it is imported, and that conversion is deterministic from the source asset plus its meta file. It runs to gigabytes on a real project and it is rebuilt on first open, which is slow but correct.
The meta files are the counterpart nobody should ignore. Each asset has a sibling .meta file holding the stable identifier that scenes and prefabs use to reference it. Losing a meta file breaks every reference to that asset, so those files must be committed even though they look like generated noise. Nothing in this template ignores them, and that omission is deliberate.
Temp, Obj, Build and Builds cover the compilation and player build output. UserSettings holds per developer editor preferences, MemoryCaptures holds profiler snapshots and Recordings holds captured playback. All are written with bracket character classes because the editor's casing has varied across versions and git is case sensitive where Windows is not.
The project file rules cover *.csproj, *.unityproj and *.sln. These are regenerated by the editor whenever the asset database changes, which means a committed copy conflicts constantly and is overwritten locally anyway. Ignoring them is right, and it is also why opening a fresh clone in an IDE requires letting the editor generate them first.
The remaining rules cover debugging and crash reporting artefacts: *.pdb, *.mdb, *.opendb, *.VC.db and their meta variants, plus sysinfo.txt and crashlytics-build.properties. The last of those can hold identifiers tied to a crash reporting account, which is another reason to keep it out.
Examples
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/
/[Mm]emoryCaptures/
/[Rr]ecordings/
ExportedObj/
.vs/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db
*.pidb.meta
*.pdb.meta
*.mdb.meta
sysinfo.txt
crashlytics-build.properties30 lines exactly as the tool writes them, before any common additions you tick.
Things that catch people out
- Never ignore *.meta. Those files carry the identifiers that scenes and prefabs use to reference assets, and losing one breaks every reference to that asset across the project.
- Large binary assets are still tracked by this template. A project with source textures and audio needs large file storage as well as an ignore file, otherwise the repository grows without limit.
- The bracket classes cover the first letter only, so a directory named LIBRARY in full uppercase would not be matched.
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 →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.
Unreal Engine .gitignore template
The Unreal template ignores compiled binaries, the intermediate build tree, the derived data cache and the saved directory, plus generated project files.
Windows .gitignore template
What the Windows template covers: the thumbnail caches Explorer writes into image folders, the folder view settings file, and installer package extensions.
VS Code .gitignore template
This template ignores the .vscode folder's contents but keeps five files back on purpose, which is the clearest statement of the commit or ignore argument.
IntelliJ IDEA .gitignore template
The IntelliJ template ignores the whole .idea directory and the module files, which is simpler than the alternative and loses some settings worth sharing.
Eclipse .gitignore template
The Eclipse template ignores the project descriptor, classpath file and settings folder, which is right for a build tool project and wrong without one.
Tools for this
- .gitignore Generator Generate .gitignore files for any project - 50+ templates for languages, frameworks, IDEs, and OS