Game Development - Part 2 - Unity and Git

After experimenting with Unity for a while I've finally built a simple game that I want to continue working on. Before I spent too much time on the game I wanted to make sure that I had a backup of the project. The options seemed to be to upgrade to Unity Pro and use the integrated version control, use GIT as an external version control system, or just backup to Dropbox as many small developers seem to do. I don't need Unity Pro at this point and I wanted to use a version control system instead of just a Dropbox backup so I choose Git and Bitbucket. 

Here are the steps I followed to add my existing Unity project to version control using Git and then push it to Bitbucket.

  1.  In Unity under Edit/Project Settings/Editor, I selected a Version Control mode of Visible Meta Files and an Asset Serialization mode of Force Text. I then saved and closed my project.
  2. I created a Bitbucket project and downloaded and installed SourceTree to use as a Git client. During install I skipped the 'Clone project' and 'Install SSH Key' steps.
  3.  In SourceTree, I selected Clone/New, Create new repository, and then set the destination path to the path of my existing Unity project.
  4. I setup my .gitignore under Repository/Repository Settings/Advanced using: and setup my name and email address under Tools/Options.
  5.  I used Repository/Add Remote to add my remote Bitbucket repository. I copied the URL from Bitbucket into the path field and added the name of the project.
  6. I then used Commit to commit my work and Push to push it to Bitbucket.
  7.  Finally, I checked Bitbucket to confirm my files were there and cloned the project on a different computer to make sure everything was working properly.

I have been working with Unity, Git, and Bitbucket for a few weeks without any problems. I'm not much of a fan of SourceTree and would probably just use the command line if I was developing on Linux. I'm using Windows and I find myself typing unix commands into the Windows command prompt whenever I try it so I will stick to SourceTree for now.

Version control with Git and Bitbucket

Now that I have a simple website up and running it is time to backup my work. Initially I was planning to backup my project using Dropbox or Box, but I decided that it is worth the bit of extra effort to setup Git and get the benefits of a version control system. I decided to go with Bitbucket instead of GitHub because Bitbucket allows you to create free private repositories.

The first step was to install and configure Git:

$ sudo apt-get install git
$ git config --global ""
$ git config --global "Your Name"

Next, I committed my files to a new Git repository and pushed it to Bitbucket:

$ cd /path/to/your/project
$ git init
$ git remote add origin
$ git add -all
$ git commit -m 'initial project commit'
$ git push -u origin master

Now my project is backed up, version controlled, and easily accessible from any computer.