What is the easiest way to use Git when working with Unity, considering, in particular, the binary nature of Unity projects? Please describe the workflow, specify what should be included in .gitignore , what settings to choose in Unity and / or the project and what else do you need to take into account?

Note : I understand that Unity developers recommend using Asset Server , but for a number of reasons I would like to use Git, that is, using Asset Server is not an option for me.

How to use Git for Unity source control? @PressingOnAlways .

1 answer 1

The recommendations below are excerpts from a personal blog .

Using Git for 3D games

Note: Not so long ago, GitHub released a plugin for Git called Git LFS to solve this problem. Now you can easily and effectively perform version control for bulk binary files!

Git works great with 3D games, except for one thing: saving versions of large (> 5 MB) media files for a long time (when updating version archives) can be problematic. We solved this problem in our projects by fixing only those binary files that are considered final . Our 3D artists use Dropbox to work with WIP - and for the above reason, and because it is much faster and easier (not many artists are eager to work with Git!).

Git workflow

The specific procedure for working with Git is more dependent on your own preferences, as well as the experience and traditions of your teamwork. Nevertheless, I would strongly recommend a methodology with the “talking” name “ Git Flow ” in the original version of the author .

I will not delve too deeply into the essence of the methodology, since the author described it perfectly well - besides, without too much “water,” so it is not difficult to understand it. I have been using this method for my team for some time and at the moment it is the best methodology we have ever tried.

Git GUI client application

This is, in fact, from the area of ​​personal preference, because with regard to the graphical interface for Git, there is a choice, including the choice of whether to use the graphical interface at all. I hasten to offer the free SourceTree application , as it is perfectly combined with the Git Flow extension. In the SourceTree tutorial, you can read about the implementation of the Git Flow methodology within this application.

What to ignore in Unity3D when working with Git

# =============== # # Unity generated # # =============== # Temp/ Library/ # ===================================== # # Visual Studio / MonoDevelop generated # # ===================================== # ExportedObj/ obj/ *.svd *.userprefs /*.csproj *.pidb *.suo /*.sln *.user *.unityproj *.booproj # ============ # # OS generated # # ============ # .DS_Store .DS_Store? ._* .Spotlight-V100 .Trashes ehthumbs.db Thumbs.db 

Unity3D settings for working with Git

For Unity3D v4.3 and higher:

  1. (For v4.5 and above, skip this step) Select the External option in Unity → Preferences → Packages → Repository .
  2. Use Visible Meta Files in Edit → Project Settings → Editor → Version Control Mode .
  3. Use Force Text in Edit → Project Settings → Editor → Asset Serialization Mode .
  4. Save the scene and project from the File menu.

Additionally

One of the negative aspects of using Unity3D and Git is that Git does not care about empty folders (and Unity creates meta files for them). As a result, unnecessary conflicts may arise.

To solve this, add a special handler to the /.git/hooks/ folder of the project repository. Thanks to the handler, after each update of the project (pull / merge), Git will check for deleted files, as well as empty folders.

Translation of an answer How to use Git for Unity source control? @ S. Richmond .