Setting up Git with Unity

Scrolling lines of console code
This takes me back to the days when my only OS was DOS.

A significant roadblock in starting any new venture is planning ahead. This requires you to know where you want to end up, and how you need to begin. The first part is easy, but working backwards to uncover the first step isn’t.

Normally, I’d dive into this experience and let harsh reality be my guide. Nothing teaches a lesson like tragedy and frustration, right? But on the other hand, nothing kills motivation quicker.

Determined not to shoot myself in the foot, I’m going to give myself the gift of version control. Thankfully, there are a myriad of tools available now that poor, novice, 8-year-old junior coder me didn’t have access to. Like git!

Git logo.

Click the link above to get git (he he) and let’s git… er get started. Once it’s downloaded and installed, boot that sucker up and we get this helpful user interface:

The Git console
Yes, my computer is named Kylo-RAM. Don’t be jealous.

Lucky for me, I got my start swimming the seas of DOS. So this is like riding a bike for me. Some people may be a bit intimidated by this interface, and if that’s you, don’t worry. It’s super easy to get help inside the program. In fact, let’s do that now.

git console help menu
Almost everything you need to know.

So, first things first: we need to link this thing to a repository. I’ll be using github (and the rest of this article will assume you are too). Creating an empty repository is simple enough. Click the shiny green “New” button, and you should have something like this:

github create repository screen
With special guest star: the corner of my mouse pointer

Name your repository after the project you’re working on. I’m going with “Version Control Example.” Make sure to check “Add .gitignore” and select Unity from the dropdown. This will make sure git ignores all the files that Unity generates in your project directory which you don’t need.

.gitignore file creation
Trust me, you do not want to manually screen the hundreds of tiny log files Unity makes.

Next, you’ll need to get a link to your repository so we can put it in git. Click the green “Code” button and copy the url in the resulting dropdown.

github repository code dropdown

Navigate to the Unity project folder on your computer and right click in the folder. You’ll see on your right click menu a couple of new options for git. The one you want is “Git Bash Here.”

Once the console opens, enter “git init” as shown below. This will link git to your project.

git init command

Now we’ll add the url we copied earlier with the following command: “git remote add origin [url]”

git remote origin [url]

If you type “git remote -v” you should see your server url named “origin.”

And that’s it! Git now knows where my project files are and where to put them when I push out new changes. With this handy tool I should save myself a LOT of frustration down the line.

In the next article I’ll cover installing Unity and getting started with game development. I hope you’ll check it out.



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
Micha Davis

Micha Davis

Unity Developer / Game Developer / Artist / Problem Solver