2

I'm starting out with Unity and I've noticed that even with small code changes result in a large git diff.

Originally, my .gitignore just had this: Temp/

but it's not doing much heavy lifting.

I found this .gitignore template on Github, but I'm curious if anyone else uses this--either as a starting point or as-is.

3

2 Answers 2

8

I use to use that same .gitignore with no issues at all, as-is. Works on both macOS and Windows.

/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/Assets/AssetStoreTools*

# Visual Studio 2015 cache directory
/.vs/

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb


# Unity3D generated meta files
*.pidb.meta

# Unity3D Generated File On Crash Reports
sysinfo.txt

# Builds
*.apk
1
  • 3
    As mentioned in the linked duplicate, the other thing you will want to do is set Force Text Asset Serialization to make assets much more friendly to diff when you do a git check-in. Commented Mar 9, 2017 at 17:43
0

I use Unity .gitignore template then added with *.unitypackage.meta From my experience, it is crucial to add *.unitypackage.meta so it won’t mess up when other PC clone the project that contains Unity Packages.

Why mess up? - "It's very common that an asset from the Unity Asset Store comes with .unitypackage files for optional features or compatibility add-ons. In such a case, the importer's machine will contain a .unitypackage and .unitypackage.meta file. The .unitypackage file is ignored by this template, but the .unitypackage.meta file is not.", Explain link.

Edited this might also serve the same purpose, !/[Aa]ssets/**/*.meta. Doc link

TLDR

Copy & Paste this

# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/

# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/[Mm]emoryCaptures/

# Recordings can get excessive in size
/[Rr]ecordings/

# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*

# Autogenerated Jetbrains Rider plugin
/[Aa]ssets/Plugins/Editor/JetBrains*

# Visual Studio cache directory
.vs/

# Gradle cache directory
.gradle/

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db

# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta

# Unity3D generated file on crash reports
sysinfo.txt

# Builds
*.apk
*.aab
*.unitypackage
*.app
*.unitypackage.meta

# Crashlytics generated file
crashlytics-build.properties

# Packed Addressables
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*

# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*

# Asset meta data should only be ignored when the corresponding asset is also ignored
!/[Aa]ssets/**/*.meta

BONUS Templates

Here is .gitignore templates for other Programs

Not the answer you're looking for? Browse other questions tagged or ask your own question.