teaching machines

CS 491 Homework – Unity and Version Control

September 3, 2015 by . Filed under fall 2015, gamedev2, specifications.

In this class I ask you to host your games on Github or Bitbucket. Putting a Unity project into version control requires a few extra steps.

  1. Binary files and version control don’t go all that well together. Some version control tools compare versions of a file line by line. Binary files are essentially one really long line. Adding one to your repository is like a throwing a Slinky under a lawn mower. As much as possible, we’d like to operate on text, which we can make Unity do through our project settings. In your project, go to Edit / Project Settings / Editor. Choose Force Text for Asset Serialization.
  2. Without a special license, Unity by itself doesn’t deal with version control. We’ll have to add, commit, push, and pull with another tool. However, we want to make sure that all the files that Unity creates are visible to this tool. Also under the Editor settings, choose Visible Meta Files for the Version Control Mode.
  3. Derived files (like our game builds) really don’t belong in our repository. They change too frequently and tend to be larger than the source that generated them. However, many of these derived files will appear in our project’s directory. We must tell our version control tool to ignore these files. In the top-level project directory, add a .gitignore file with these contents:
    /[Ll]ibrary/
    /[Tt]emp/
    /[Oo]bj/
    /[Bb]uild/
    /[Bb]uilds/
    
    # Autogenerated VS/MD solution and project files
    *.csproj
    *.unityproj
    *.sln
    *.suo
    *.tmp
    *.user
    *.userprefs
    *.pidb
    *.booproj
    
    # Unity3D generated meta files
    *.pidb.meta
    
    # Unity3D Generated File On Crash Reports
    sysinfo.txt

See the official Unity documentation for more details.