Foundations: Setting up version control

So, you want to be a Unity developer? Join the club! No, I mean it! Let’s take this step by step together. Before we type our first line of code, let’s lay some foundations.

What is version control?

Version control is a powerful solution for file management that allows you to:

  • Track all changes made to multiple files in a directory

There are multiple products that support version control, but I want to focus on one of the most popular: Git.

Git

Git is a free open-source version control software which was originally built to run through the command line on a Bash shell.

Git Bash terminal

There are also graphical user interfaces (GUIs) available for Git as well as integrations through code editors — though the basic processes remain the same whether you utilize Git Bash or a GUI version.

Installing Git

Before we can get started on how to use Git, let’s get it installed.

To download Git, open git-scm.com and download the latest version available for your operating system.

Git Download webpage

You can utilize the default installation settings to get started, but there are two options that would be beneficial to note:

  • You can customize the name of your default branch. Traditionally, your default branch would be labeled as your master branch, but this convention is in the process of changing. GitHub’s current standard is to use main, so you can set that here to make it easier to link with GitHub later.
Git Installer — Set your default branch name
  • You can set your default text editor for Git. For certain commands, Git will open a file in a text editor you to update to complete your request (ie. entering the comment for a commit). You can select your preferred default text editor during installation.
Git Installer — Choosing your default text editor for Git

Starting Git for the first time

Once Git is downloaded, it can be opened from the start menu by clicking Git Bash. This will open up a Bash shell that can process Git commands.

Git Bash terminal window

Git interacts with files and directories, so location is very important. When opening Git from the start menu, it will open in a default location based on where it was saved. Your location, or current working directory, is visible in the top bar of the Git Bash window. For me, that is: /c/Users/erinb. Before using version control with a project, we’ll need to navigate to the project directory.

Navigating to the project directory

Since Git runs in the Bash shell, you can use Bash commands to move around.

  • ls to List Files: This will list all of the files and folders in your current directory.
ls command in Git Bash terminal
  • cd to Change Directory: This will allow you to change your current working directory.

If you enter cd followed by the name of a subfolder in your current location, you will move into that folder.

cd command with filename in Git Bash terminal

If you enter cd followed by .. (two periods), you will move up to the parent folder of your current working directory.

cd command with .. in Git Bash terminal

Alternatively, you can also access your project directory through your computer’s file system (ie. File Explorer for Windows). Once there, right-click and select Git Bash Here.

Right-click in the project directory to Git Bash Here

This will open a Git Bash terminal in that location.

Git Bash terminal after using Git Bash Here

So, now we know what version control is and we installed Git. We know how to open it and move between directories. Tune in next time for more on how to create a remote version of your project with Git and GitHub.