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
- Revert changes, either at a single point or as a group
- Create and manage different versions of the same project for feature and hotfix testing and more
- Communicate changes to the project between local and remote versions, allow multiple users to collaborate on a single project at the same time
There are multiple products that support version control, but I want to focus on one of the most popular: Git.
Git is a free open-source version control software which was originally built to run through the command line on a Bash shell.
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.
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.
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.
- 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.
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 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.
- 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.
If you enter cd followed by .. (two periods), you will move up to the parent folder of your current working directory.
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.
This will open a Git Bash terminal in that location.
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.