Unity .gitignore and Git for Game Development
.gitignore templates for Unity, Unreal, and Godot, Git LFS setup, workflows, and large binary strategies. The Unity template is explained block by block.
Version control for games is harder than for web or mobile apps because game projects contain large binary files (textures, models, audio) that Git was not designed for. This guide covers the essential setup: .gitignore templates for Unity, Unreal and Godot, what each block of the Unity template excludes and why, the two things a bare template cannot tell you (Unity's .meta files must be committed, and ignoring a folder does nothing once Git already tracks it), Git LFS for binary assets, and the workflows most game teams use daily.
.gitignore Templates
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
[Bb]uilds/
[Ll]ogs/
[Uu]ser[Ss]ettings/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db
*.pidb.meta
*.pdb.meta
*.mdb.meta
crashlytics-buildid.txt
sysinfo.txt
*.apk
*.aab
*.unitypackage
*.appWhat each block excludes
Generated folders
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
[Bb]uilds/
[Ll]ogs/
[Uu]ser[Ss]ettings/Unity rebuilds all of these from your assets and project settings. Library is the import cache and is usually the largest folder in the project by a wide margin, often several gigabytes. UserSettings holds per-developer editor layout and preferences, so sharing it just overwrites your teammates' window arrangements. The bracket notation matches both capitalisations, because Unity has used both over the years and Git is case-sensitive on Linux and on case-sensitive macOS volumes.
IDE and solution files
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefsUnity regenerates the C# project and solution files from your assembly definitions and package list on every reimport. Two developers with an identical project will produce different files, so committing them creates conflicts that resolve to nothing useful. Anyone opening the solution gets a freshly generated copy.
Debug symbols and editor caches
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db
*.pidb.meta
*.pdb.meta
*.mdb.metaDebug symbol databases and editor caches, all regenerated on compile. Note the .meta entries here: these are the exceptions to the rule that .meta files must be committed, because the assets they describe are themselves ignored. A .meta file for an ignored asset is meaningless.
Crash and diagnostic reports
crashlytics-buildid.txt
sysinfo.txtWritten per machine and per build. crashlytics-buildid.txt changes on every build when Firebase Crashlytics is installed, which makes it a permanent source of noise in your diff.
Build output
*.apk
*.aab
*.unitypackage
*.appCompiled builds and exported packages. These are large binaries that change completely each time, so Git cannot delta-compress them and the repository grows by the full size on every commit. Publish them as CI artefacts or releases instead.
Commonly added extras
Situational, so they are not in the base template. Add the ones that match your team's tools.
Editor and OS clutter
.vs/
.idea/
.vscode/
*.swp
.DS_Store
Thumbs.dbPer-developer IDE state and operating system metadata. .DS_Store on macOS and Thumbs.db on Windows appear in every folder anyone browses, so they are worth excluding globally as well as per project.
Recordings and profiling captures
MemoryCaptures/
Recordings/
[Cc]rashlytics/Memory Profiler captures and Recorder output are large, local, and rarely useful to anyone else. Add these if your team uses those tools, otherwise the folders never appear.
Asset Store tooling
Assets/AssetStoreTools*
Assets/Plugins/Editor/JetBrains*Publisher tooling that Unity drops into Assets and that should not travel with the project. Note these sit inside Assets, so their .meta files are ignored automatically by the trailing wildcard.
Commit your .meta files
This is the mistake that costs the most time, because the damage shows up later and looks random. Every asset in Unity has a companion .meta file holding its GUID, and every reference in your scenes, prefabs and materials points at that GUID rather than at a file path. Ignore .meta files and each developer generates different GUIDs for the same asset, so references that work on your machine resolve to nothing on everyone else's. Missing script references and unassigned materials are the usual symptoms.
Set Asset Serialization to Force Text in the same panel. Scenes and prefabs are then written as YAML rather than binary, which is what makes them diffable and merge-able at all.
The template above ignores three .meta patterns (*.pidb.meta, *.pdb.meta, *.mdb.meta). Those are the exception, not the rule: the assets they describe are themselves ignored, so their .meta files describe nothing.
Library is already committed. Now what?
.gitignore only prevents untracked files from being added. It has no effect on files Git already tracks, which is why adding Library to .gitignore appears to do nothing on an existing repository. Stop tracking it explicitly:
# Stop tracking, but keep the folder on disk
git rm -r --cached Library
git rm -r --cached Temp obj Build Builds Logs UserSettings
git commit -m "Stop tracking Unity generated folders"
git pushThe --cached flag is what keeps your local files. Without it you delete the folders from disk as well, which is recoverable for Library, since Unity rebuilds it, but not for anything you meant to keep. Teammates receive the deletion on their next pull and their local Library rebuilds automatically on the next Editor launch.
Check what is actually tracked before and after:
# List tracked files that your .gitignore now excludes
git ls-files --cached --ignored --exclude-standard
# Confirm a specific path is ignored, and by which rule
git check-ignore -v Library/somefileRemoving the folders from the current commit does not shrink the repository, because the history still contains every version. If the clone size is the problem you need to rewrite history with git filter-repo, which changes every commit hash and requires all collaborators to re-clone. Worth it on a repository that has grown to gigabytes; not worth it otherwise.
What must stay in the repository
Excluding too much is as damaging as excluding too little, and harder to notice. These are not optional:
Assets/and every .meta file inside it. Your entire project.ProjectSettings/. Input axes, physics layers, quality levels, player settings, tags. The project behaves differently without it, and the differences are subtle enough to waste a day.Packages/manifest.jsonandPackages/packages-lock.json. These pin your package versions. Without the lock file, teammates can silently resolve different versions.
Note that UserSettings/ is ignored while ProjectSettings/ is committed. The names are similar and the consequences of confusing them are not.
Git LFS Setup
git lfs install
git lfs track "*.png"
git lfs track "*.jpg"
git lfs track "*.psd"
git lfs track "*.tga"
git lfs track "*.wav"
git lfs track "*.mp3"
git lfs track "*.ogg"
git lfs track "*.fbx"
git lfs track "*.obj"
git lfs track "*.blend"
git lfs track "*.unitypackage"
git lfs track "*.asset"Add these to .gitattributes. Commit .gitattributes before adding binary files.
Common Workflows
Feature branch
git checkout -b feature/player-movement
# work on your feature...
git add -A && git commit -m "Add player movement"
git push -u origin feature/player-movement
# create PR on GitHub / GitLabRevert a broken commit
git revert HEAD # safe: creates a new commit
git reset --soft HEAD~1 # undo last commit, keep changesStash work in progress
git stash push -m "WIP: inventory UI"
git stash popResolve merge conflict
git merge main
# resolve conflicts in your editor
git add .
git commitTag a release build
git tag -a v1.0.0 -m "Release 1.0.0"
git push origin v1.0.0Large Binary Strategy Reference
| Strategy | Max file size | Cost | Best for |
|---|---|---|---|
| Git LFS | ~2 GB | Free tier varies | Most game studios |
| Git Annex | Unlimited | Self-hosted | Large studios with own infra |
| Perforce (assets only) | Unlimited | Per-seat | AAA studios |
| .gitignore + cloud sync | N/A | Varies | Solo devs, small projects |
Related Unity errors
- Referenced script is missingWhy Unity reports a missing script on a GameObject, how to find which object it is, and the five causes from deleted files to broken .meta GUIDs.
- Script class cannot be foundWhy Unity refuses to add a script component, ranked from compile errors and name mismatches to namespaces and abstract classes, with the fix for each.
- Multiple precompiled assembliesWhy Unity reports duplicate precompiled assemblies, why Newtonsoft.Json causes it most often, and how to find and remove the duplicate safely.
Related Tools
Scripting Order
Interactive Unity MonoBehaviour lifecycle diagram. When does Awake, Start, Update, and every callback run.
Platform Capabilities
Which platforms support haptics, HDR, ray tracing, VRR, and more. Filterable matrix.
Object Pool Generator
Generate production-ready Unity object pooling code with configurable options.
Unity Error Decoder
Paste a Unity error or stack trace and get the page that explains it. Ranked causes and fixes, one page per error message.
Frequently asked questions
Should I use Git or Perforce for my game project?
How do I set up Git LFS for a Unity project?
Why is my Unity .meta file causing merge conflicts?
How big can a Git repo with LFS get before it becomes painful?
Why is Library still in my repository after adding it to .gitignore?
Should I commit .meta files in Unity?
Should ProjectSettings be committed?
Last updated: