Using Version Control With Unity

SO COLORFUL

When you’re working on a project, especially with a team of more than one, you need to be sure you have a solid and reliable method of backing up your data. I’m personally more familiar with the repository system of git , so we’ll be taking a look at that in relation to Unity development projects.

NOTE: this is being done in a Windows environment, however much should still translate to other OSes.

There are two ways one can use it — the command line or GUI clients.

First, let’s look at using the command line with Git Bash (GB), then we’ll look at using a desktop client and assess the pros and cons of both.

To begin, you’re going to want to download and install GB for your system which you can do here: https://git-scm.com/downloads.

Preparation Steps

  • Create a folder for your Unity project
  • sign up for an account on Github
  • sign up for an account on Unity

Navigating to Your Project Folder

Method One
Open GB and navigate to your project folder. Use the ls command to see a list of accessible folders and directories. Use the cd command to change directories. When typing the name of your target directory, you can type the first three letters then the Tab key to auto-complete the name.

NOTE: if there are spaces in the directory name, demarcate them with a \ or type the folder name in quotation marks.

Method Two
In Windows Explorer, navigate to your project folder, right+click and select Git Bash Here. This will open the Git Bash window already present in the project folder.

REPOSITORIES

Initializing the Local Repository
Once you’re in your project folder, type git init to create the local repository.

Now open your internet browser and navigate to github.com.

Initializing the Remote Repository
Log in to github if you aren’t already and create a new repository by clicking the big green NEW button.

Name the repository and add a description which will help you and anyone else working on it remember what it’s for and to bring up to speed any possible new team members.

The README file would essentially be your wiki for your project. While advisable to have, we’ll skip it for now.

From the drop down menu select the Unity gitignore template file.

Click the Create repository button.

Linking the Local and Remote Repositories

In github, click the green CODE button and copy the repo URL you find there to your clipboard.

In GitBash, type the following and paste the repo URL after it then press Enter:

git remote add origin [repo URL]

Type git remote -v to verify the connection between the repos — it should return a message with two near identical lines of the URL with (fetch) at the end of the first and (push) at the end of the second.

Now with the repositories set up and linked, we’ll move into actually pulling and pushing data to and from the remote in the next article.

Thank you so much for reading, and let me know if there’s anything you’d like to see covered in here.

Be sure to follow me here to not miss a post, and sign up for my email list to get even more updates about projects and other exciting things I’m working on.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store