Search code examples
gitunity-game-enginegitignore

Git ignoring obj files in Unity project


I'm working on a unity project with git and i'm using a .gitignore file found on github. I don't recognize which rule of the gitgnore file make this happen: Git is ignoring the .obj files in "projectname/Assets/objs".

This is the .gitignore:

# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/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/

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

# 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

# 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/*

The other question is: do I need to track these files? files to track???


Solution

  • No, you don't need to (and shouldn't) track Library folder. It's Unity's cached data which regenerates automatically if not present. Your .gitignore seems to exclude Library correctly, so it shouldn't be tracked - are you sure you placed the file exactly at the root of the project? It should be on the same level as folders such as Assets and Library.

    To check if your .gitignore is responsible for not including something, use this:

    git check-ignore -v -- some/path/to/check
    

    It will output the responsible rule, if any.