Day 1 — Integrating GIT with Unity Part 1
Hey and welcome!
Alright first thing’s first we’ll need to get this project setup and working with GIT Version Control.
“Why would I want to make use of version control when I like to live dangerously?” Great question, I used to think like that as well, I wasn’t even aware that GIT could be integrated into Unity but after learning more about it it’s a fantastic little thing that can prevent some heartache. While handy when working on a project by yourself it really shines when you’re working on a group project so I’m going to show you how to get it working with Unity and why it’s the best thing ever.
Downloading GIT
Alright first step is to get GIT downloaded which is easy enough by typing “git download” into Google and making sure that you’re getting it from git-scm.com and that you’re choosing the version relevant to the device you’re on like Windows 32/64 bit, macOS etc.
In the setup wizard you’ll be assaulted by a bunch of options to OK which it’s fine to go for the defaults if you’re not sure what’s up, certainly pick and choose things if you’re more familiar with them but for the purposes I have in mind here the defaults are fine.
Getting hands on with GIT
Marvelous, now it’s installed and ready for you to mess about with. To get started you’ll want to search for the Git Bash program in your computer and run it which will open up a CMD line for you. Anyone not familiar with working in the CMD line it honestly looks more daunting than it actually is, all you need to know are the following commands and you’re set:
- ls
- cd
- git init
- git remote add origin
- git pull origin
- git status
- git add
- git commit -m
- git push origin
- git branch
- git switch
- git log
First we’ll need to navigate to our Unity project folder with the use of the cd (Change directory) command. So for example if your project is located in Documents > Unity Projects you will want to first type cd Documents and then cd “Unity Projects” in order to access the folder. To see a list of the current directories that you can access you type the ls command, it will also help give you an idea on where you’re currently GIT bashing into.
Alternatively there’s a much easier way to go about this if you’re not familiar with switching between directories. Simply navigate to the folder containing your unity project through the file explorer as you would normally and then right click inside the folder and choose the Git Bash Here option.
Now we’re definitely cooking, from here it’s time to create your repository tot connect with your project, for the purposes of this article we’ll be using Github. When you’re creating you’re Github repository you’ll need to make sure that you select the gitignore option and choose the Unity template for it, this will stop GIT from committing unecessary files to your repository.
With your repository created it’s time to initialize GIT with the project by typing the git init command. Once that’s done it can now be linked to your Github repository. Grab the URL of your repository and use the git remote add origin https://exampleurlhere.com command. The origin part in this command is specifying the name of the server we’ll be using.
So ends part 1 and the arguably easy section. This topic will be three parts long with the next part going over commiting changes and pushing your project files into your Github repository.