Principle to avoid Headaches with Git and Git LFS with Unity.
Objective: Understand how to make your life easy with git, git lfs in a unity project.
The concept of git and LFS
- You put text-based files in git
- You put static binary files in LFS
- You exclude other stuff like generated files (because they are auto-generated on compile, on the build, or at runtime, so there is no need to track them.)
But to do so effectively, you need:
- Know what files are text-based and what files are binary, this is usually done by looking at file extensions.
- Know where these files are so that you can include or exclude them by paths.
- Know how to merge these files properly, either with git, or some third-party merge tool like UnityYAMLMerge.
It used to be relatively easy, you can Google for a gitignore, and guarantee it works as intended.
Not today, let me explain:
- .asset/.unity files can be text or binary or both:
- a simple scriptable object? text
- lighting data or terrain data or nav mesh? binary
- text mesh pro font asset? both (because you can store binary data in YAML)
- a unity scene with pro builder mesh in it? both (because these meshes are encoded as binary data)
- - things are generated without you knowing:
- Addressables put generated content under both /Assets/AddressableAssetsData/ and /Assets/StreamingAssets/ (I understand why it does it, but then it’s up to me to tell git and LFS to exclude these generated content, or track them but face frequent changes)
- - merge tool is no longer at a fixed location:
- With unity hub, we no longer install Unity at a fixed location, hence unityyamlmerge location can change too, good luck updating it each time.
Credit goes to this man I just want to keep this as my reference link to the discussion:https://forum.unity.com/threads/life-with-unity-git-lfs-a-rant-and-a-call-for-help.653191/