I’ve been spending a lot of time recently trying to get used to the new world of the virtual office. My knowledge of source control using Perforce or SVN and game engines such as idTech or Unreal Engine are being replaced by the flavours of the month technologies – Git and Unity. This transition has brought a lot of joys and a lot of new ground to cover as I get used to fully distributed source control, posix like tools and C# coding at a high level of abstraction, without being able to peak under the hood to the murky bits.

Along the way I seem to be hitting my head and knocking my knees of every bleeding edge there is. With that in mind, if I can save someone else some of the pain of my ignorance then it’s all been worth it. I’ve started working on a Unity template git repo available on the tcg.hackspace for ease of forking (the repo is currently setup to provide Unity meta file support but I will look to add default .gitignore and Git LFS attributes in the future).

There are a couple of setup steps that are a MUST for effective functioning of a Git repo and the hopes of not bursting the download limits of https and the hard timeouts of your cloud hosting provider.

Enable Git LFS from the start

Git Large File Storage (LFS) is essential for any kind of development that requires large or binary files such as images, videos or model data to be used as part of the build process. Git LFS allows these large files to be stored in a seperate content cache and only downloaded when required, reducing the size of the repository and making cloning and pulling of large projects manageable. github and bitbucket both offer Git LFS storage as part of their offerings.

  1. Go to https://git-lfs.github.com/ to download and install the Git LFS extension.
  2. Open git bash and type:git lfs install
  3. Make sure your .gitattributes has all the file types for big files you use in your project. Don’t know what they are? Then use something like windirstat on your project folder to find out. Here’s an example .gitattributes file to start out with:

proj_root_dir/.gitattributes

*.fbx filter=lfs diff=lfs merge=lfs -text
*.FBX filter=lfs diff=lfs merge=lfs -text
*.mb filter=lfs diff=lfs merge=lfs -text
*.ma filter=lfs diff=lfs merge=lfs -text
*.exr filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.psd filter=lfs diff=lfs merge=lfs -text
*.tif filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.mov filter=lfs diff=lfs merge=lfs -text
*.avi filter=lfs diff=lfs merge=lfs -text
*.bnk filter=lfs diff=lfs merge=lfs -text
*.wav filter=lfs diff=lfs merge=lfs -text
*.wem filter=lfs diff=lfs merge=lfs -text
*.akd filter=lfs diff=lfs merge=lfs -text
*.cache filter=lfs diff=lfs merge=lfs -text
*.dat filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.bundle filter=lfs diff=lfs merge=lfs -text
*.pdb filter=lfs diff=lfs merge=lfs -text
*.exe filter=lfs diff=lfs merge=lfs -text
*.dll filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
*.chm filter=lfs diff=lfs merge=lfs -text

Don’t commit more than you need

If something doesn’t need to be in the Git repo then it probably shouldn’t be. Make sure you use .gitignore file properly to filter out files that need to be shared from those that don’t. Here’s an example .gitignore file to start out with:

proj_root_dir/.gitignore

# 3rd party files
#

# wwise intermediate files
**/.cache/
*.akd

#maya intermediate files
**/incrementalSave/

# Unity generated
#
Temp/**
Obj/**
UnityGenerated/**
Library/**
build_ios/**
build_android/**
build_html5/**
build_win/**
project_android/**

# Ignore: name DOT meta
*.meta
# Include: name DOT extension DOT meta
!*.*.meta

# Visual Studio / MonoDevelop generated
#
ExportedObj/
*.svd
*.userprefs
*.csproj
*.pidb
*.suo
*.sln
*.user
*.unityproj
*.booproj

# OS generated
#
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
Local/*

# misc
#

Set Unity’s asset serialisation TO ‘Force Text’

The second thing to mention is Unity Text Serialisation – Git has a very hard time handling binary assets so switch to ‘Force Tex’ mode to enable YAML encoding of Unity assets.

  1. Open the project folder in Unity
  2. Goto ‘Edit > Project Settings > Editor
  3. Check ‘Version Control > Mode‘ is set to ‘Visible Meta Files
  4. Check ‘Asset Serialization > Mode‘ is set to ‘Force Text
  5. Save everything and commit the changes to Git.

Don’t trip over Unity meta files

Forrest Smith has written about Unity meta files well enough that I don’t need to repeat his words here but do follow this advice to handle them properly in Git and save yourself a lot of headaches in trying to reconstruct your unity scenes from the ground up.

[UPDATE – turns out the 3pjames’ git hooks clash with the ignore folder meta files pattern, as such I’ve added the tcg.hackspace.unity-git repo instead]

Add the tcg.hackspace.unity-git repo as a submodule to your git repo:

$ git submodule add https://bitbucket.org/TeaClipper/tcg.hackspace.unity-git

Directory meta files should be ignored from the repo:

$ ./tcg.hackspace.unity-git/scripts/ignore-dir-meta-files.sh

I’d then recommend going into git bash and removing any old folder meta files before installing the git hooks:

$ git rm – cached *.meta
$ git add *.meta
$ git commit -m “[-] removed folder meta files from repository”

Install git hooks via git bash to check that assets and their corresponding meta files are kept in sync:

$ ./tcg.hackspace.unity-git/scripts/install-hooks.sh

The easy part

Now all you have to do is go and make a game! …using continuous integration, testing, deployment and analytics…

Save

Save