Techshop

Unity Tutorial 4 - Git and Unity

Version Control and Unity is possible, it's just a little messy.

Problem 1

Unity creates 'meta' files. It basically creates a uuid for every file in the filesystem and creates a file called <filename>.<ext>.meta and puts the uuid in there.

The idea is so that it can identify all files by this identifier instead of the file name. It's so that files can be renamed and not lost.

Problem 2

There is a cache folder. Unity stores a cache of the state of the editor. This will be totally different from person-to-person and any big changes will make them so different that it will completely corrupt the game.

Problem 3

BIG binaries.

There are a lot of binary files in games. BIG images. Textures tend to be huge, a 2048x2048x32 bit, uncompressed image is about 16mb.

There's also MP3, WAV, MP4 movies, model files, lots of big files that could end up in GIT.

GIT does not like big binary files, and will not like them changing as it can't DIFF them and store the differences.

Solution for 1

Make sure meta files are stored as part of the push to GIT. Don't ignore them as fluff. They are a single line of text normally and don't change.

 Solution for 2

Totally gitignore the Library folder.

When using GIT to pull, delete the Library folder. Pull. Merge. Then start Unity.

Unity will rebuild the Library folder if it doesn't exist. It can be slow on a big project, it has to rebuild the entire project. But it's the only solution.

Solution for 3

git-lfs

Install GIT-LFS. Enable it for the remote repository. Store all large files in git-lfs. Only store the smaller files and non-binary files in git proper.

Code for this project will is in the repository at https://github.com/jchive/unity-tutorial-coin and tags (or a Git Hash) for each step will be signified at the end of a significant process.

Unity - A simple tutorial < Unity Tutorial 3 - Navigation Unity Tutorial 5 - Building a Project >