What are best practices for using Git source control with Unity 3D, particularly in dealing with the binary nature of Unity 3D projects? Please describe the workflow, what paths would be included in .gitignore, what settings should be set in Unity and/or the project, and any other special things that should be noted.
Note: I realize that using the Asset Server is the Unity-recommended way, but I would like to use Git for a variety of reasons. Please no answers that state or argue that I should just use the Asset Server. The Asset Server really isn't an option for me.
Just adding in on the subjet of Gitignore. The recommended way only ignores Library and Temp, if its wihtin root of your git project. if you are like me and sometimes need unity project to be a part of the repo, not the whole of the repo, the correct strings in gitignore would be:
To add to everything stated, it it also ideal to use git lfs with Unity. I have been using this since it came out and it has had no trouble.
You will want to add this .gitattributes next to your .gitignore file
That is my rolling file list. If you use additional binary files not lists, add them.
I also have files configured to use yamlmerge, you would need to set this up. You can read about it here: http://docs.unity3d.com/Manual/SmartMerge.html
You can use Github for Unity, a Unity Extension that brings the git workflow into the UI of Unity.
Github for Unity just released version 1.0 of the extension.
What is GIT?
Git is a free and open source distributed version control system (SCM) developed by Linus Torvalds in 2005 ( Linux OS founder). It is created to control everything rom small to large projects with speed and efficiency. Leading companies like Google, Facebook, Microsoft uses GIT everyday.
If you want to learn more about GIT check this Quick tutorial,
First of all make sure you have your Git environment set up.You need to set up both your local environment and a Git repository (I prefer Github.com).
GIT client application Mac/Windows
For GIT gui client application i recommended you to go with Github.com,
GitHub is the place to share code with friends, co-workers, classmates, and complete strangers. Over five million people use GitHub to build amazing things together.
Unity3d settings
You need to do these settings
Switch to Visible Meta Files in Edit → Project Settings → Editor → Version Control Mode.
Enable External option in Unity → Preferences → Packages → Repository
Switch to Force Text in Edit → Project Settings → Editor → Asset Serialization Mode.
Source: Using Git With 3D Games Source Control
In Unity 4.3 you also had to enable External option from preferences, but since Unity 4.5 they dropped option for that, so full setup process looks like:
Visible Meta Files
inEditor → Project Settings → Editor → Version Control Mode
Force Text
inEditor → Project Settings → Editor → Asset Serialization Mode
File
menuAlso our team is using a bit more extended
.gitignore
file:Note that the only folders you need to keep under source control are
Assets
andProjectSettings
.More information about keeping Unity Project under source control you can find in this post.
I would rather prefer that you use BitBucket, as it is not public and there is an official tutorial by Unity on Bitbucket.
https://unity3d.com/learn/tutorials/topics/cloud-build/creating-your-first-source-control-repository
hope this helps.