0

I am currently trying to block changes to my git version control that deal with .asset files in a certain folder. Even if I put in the following line, .asset files and their associated .meta files get added to the commit. I have even tried blocking the specific folder that that data is in but it still pushes. I am wonder if one of the previous lines in the gitignore is messing something up.

*.asset

# 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/
[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
*.unitypackage

# Crashlytics generated file
crashlytics-build.properties

# SongPong Specific ___CUSTOM___
*.swp
*.asset
#Ignore all .meta file
*.meta
#But not source file with postfix. which is everything but a folder
!*.*.meta

Furthermore, if anyone uses any better/more updated gitignores for unity, I would also appreciate that

phd
  • 82,685
  • 13
  • 120
  • 165
Sean Hruz
  • 3
  • 1
  • 2
  • **Don't ignore the meta files!** and also why would you want to ignore .asset files? Are you not interested in version controlling all your prefabs etc? ... If you push it like this anyone else pulling/cloning the project will have missing prefabs so any scene content build from prefabs will be broken! – derHugo Jun 14 '20 at 14:46

1 Answers1

0

Keep in mind, the gitignore doesn't magically remove files from previously commits.

As for why the assets are still added, I can't find a problem source. Your meta files are still added if they have a prefix or if they are within /[Aa]ssets/**/, based on this line:

!/[Aa]ssets/**/*.meta

Also, you should ALWAYS push meta files associated to files within your project! If you don't and someone else pulls the project, then new unique meta files will be created in the other project as well. Now you both have mismatching meta files, which means your "pointers" are not synced anymore and you will run into missing reference problems. Imagine someone creates a prefab and references it in some public field in the inspector and then pushes that change. You pull it, but the referenced ID doesnt exist for you, because your meta file for that same file has a different ID. Thus sudenly you get a missing reference and the file is no longer in that public field.

Florian Wolf
  • 171
  • 7