Search code examples
gitunity-game-enginegitlab

Unity Git repo breaks when cloned


This is the first time I use Unity professionally and something very strange is going on. The project contains 10 different interactive 2D scenes with their corresponding game objects and scripts, all is good in that regard.

Now, I am trying to setup Unity with Git, I have gone through countless of .gitignore and .gitattributes templates as well as setting up git LFS currently I believe. For example, Library folder is not pushed to the remote repository. I push to master but any of my colleagues who try to clone the repository get an empty project when they open it in Unity Editor. All the assets, scenes and media is there however the editor shows the default Untitled -> Main Camera -> Directional Light. Indeed I deleted the local repository, and cloned it myself and I got the same issue. I have deleted the master and re-done, I have re-imported the project in the editor probably a million times therefore I am running out of ideas here.

I noticed that when I clone the repository and later copy paste the library folder from the backedup/original/local repository into the cloned one, all the scenes appear just fine. This is more confusing to me because as stated (and researched online) it is widely accepted that the Library folder should not be pushed/shared. However how is my team suppose to clone the project with all the scenes appearing in? Do I need the library folder or not?


Solution

  • Thank to everyone who commented and tried to help me out. I also posted the same question on Unity's forums and apparently this is the intended workflow, that is, anyone cloning the project gets a clean editor until they drag and drop the required scenes (or use an addon/scripting to do that). At first that did not make sense to me but imagine working on a huge game with thousands of scenes while you have to work on just 5 of those. That would create a huge fuss for no reason having to close all the superfluous scenes rather than just opening the required ones.

    What scenes you have opened is stored in the Library folder, which indeed should never be put in a version control environment.