Unity + Git = Components missing files

I’ve never worked with git and unity before so I’ve read several online tutorials about the process and correct workflow.

I believe I’ve done everything properly yet I’m getting an annoying issue. I just cloned my private repo from bitbucket to my new laptop and any component that has files attached to it is missing those files.

  • Scripts - “The associated script can not be loaded.”
  • Sprite Renderer - Missing sprites
  • Colliders - Missing materials
  • etc…

My .gitignore:

Library
Temp
*.sln
*.csproj
*.unityproj
*.pidb
*.userprefs

Edit → Project Settings → Editor:

  • Version Control: Visible Meta Files
  • Asset Serialization: Force Text

This seems like a common issue (I looked online and talked to friends). What could be the cause and is there a proper solution?

Solved.

After enabling the Editor options you must delete the Library and re-open the project before pushing up.

Also make sure .gitignore does not have *.meta files.

In Unitys manual it says:


When backing up a project, or adding a project to a Version Control
Repository, you should include the
main Unity project folder, containing
both the Assets and ProjectSettings
folders. All the information in these
folders is crucial to the way Unity
works. You should omit the Library and
Temp folders for backup purposes.


Note: Projects created in Unity 4.2
and earlier may not have .meta files
if not explicitly enabled. Deleting
the Library folder in these projects
will lead to data loss and permanent
project corruption because both the
generated internal formats of your
assets and the meta data were stored
in the Library folder

https://docs.unity3d.com/Manual/BehindtheScenes.html


So I shall be alright deleting the Library then? I’m using Unity 2018.3.13f1