Git Source Control for games with Assets (Unity3D etc...)

2015/11/27 By Boarnoah

This guide will focus mainly on Unity 3D (as an extension to this excellent post), but should be equally applicable for most other game/multimedia projects that need Git source control.

It is very tempting to at least initially start storing binary assets along with your source code when working on a game. Its generally understood that Git doesn't do great job handling binary assets, leading to slowdowns later down the line. Removing binary files later does not decrease the size of your repo as the assets are now permanently a part of your repository’s history.

The solution then comes to storing these binary assets separate from your source, while still maintaining parity across all developers. Online data storage services such as Google Drive/Dropbox are usually good enough to handle this. One important note would be to do regular backups yourself to other storage medium and as neither service mentioned has much in the way of version history.

For this guide we'll showcasing an example that's hosted publicly on GitHub (this project has binary assets on Google Drive), the Unity's specific steps can be ignored for other platforms.

For convenience we use Link Shell Extension to create the Symbolic Links on Windows and SourceTree as our Git client.

Configuring Unity3D to serialize data (Unity Specific)

Under Project Settings – Editor set Visible Meta Files and Asset Serialization: Force Text

The meta files help Unity to reference Assets in Editor. Forcing Asset Serialization will make Unity write .scene files in human readable text. Therefore you can directly add .scene files to your git repository.

IMPORTANT: Asset serialization is HIGHLY recommended, having binary scene files will wreck havoc on your repository/cloud storage if say two developers tweak objects in the scene.

Cloud Storage (Google Drive)

This is where we'll be storing/syncing our binary assets. For the example project we add developers with share access to the directory. The files are synced to their local computer with the desktop application (both Google Drive/Dropbox have standalone applications).

Linking the Cloud Storage files to the Project Directory

We can symbolic link folders from our cloud drive (of which the local copy is synced online) to it's location in our project repository.

Adding binary assets to .gitignore

To keep things simple we have kept all our binary cloud synced assets in folders, and we just .gitignore the entire “asset” folders at a time.

Hope this is useful for anyone contemplating how to manage their binary assets with Git. We don't have a comment section on this blog yet, but we can be reached through email.