Unity and Git

June 26, 2018

Hey there! The winds have blown me in a new direction and this site is now just an archive for posterity's sake. All the new action will be happening at StayWildGames.com. I'll have a writeup detailing the move soon.

Well, it’s been a fun couple days. I’m basically splashing around the pool trying to figure out how to swim. One of the first things I felt like I needed to do was get Git up and running so that as I work through practice projects I have the repos to look back on and reference.

My brief research seems to acknowledge the fact that Unity and Git might not always play so well together. But maybe that’s starting to change if you’re okay using GitHub. I managed to get a brief proof of concept up and running so here’s what I did.

Download GitHub for Unity

Go here and download this Unity plugin or use the Asset Store tab and search for “GitHub”. I’m still fuzzy on all the terminology, but once it’s downloaded I believe you’ll need to import it into your project so that it’s included in your Plugins folder.

Final import dialogue

Open the GitHub Panel

Go to Window > GitHub and you should see a new panel next to the Inspector Panel. Inside that panel it should prompt you to initialize a new repo. Ideally they do this with all the settings that help Unity and GitHub play nice. Go ahead and initialize the Git repo.

Update .gitignore

This section is probably redundant now as explained here.

One thing I quickly noticed was that it didn’t do much with your .gitignore file. Luckily I had read this post and knew there were a few things I was going to want to exclude right off the bat.

Now, that blog post from thoughtbot is a year old and this GitHub for Unity plugin is brand new. I’m letting the plugin handle most of what they describe in their blog post, but I am taking some pointers from the .gitignore file they suggest.

I’m actually using JetBrains’ Rider so my .gitignore looks something like this:


# Ignore JetBrains Rider directory

# Unity3D generated meta files

# Unity3D Generated File On Crash Reports

# Builds

Commit and Publish

Once the .gitignore stuff was settled I was able to make the first commit for the repo. After that things got a little weird. I tried letting the GitHub plugin do the creating of the repo, but didn’t get the results I’d expect. You’re able to sign in to GitHub here:

GitHub Sign In

That worked fine. The next step was to publish. I did get the plugin to create a GitHub repo under my account, but it didn’t remember the remote repo after doing so. Plus it just hung there a bit and I had to check GitHub itself to find out whether it worked or not.

I had to copy the repo url from GitHub and paste it in the Remote: origin field under Settings.

Remote origin field

Once I did that and clicked Save Repository I had to close the project and then reopen it in order for that remote repo location to actually be saved. Once that was all good, the option to Publish went away and I had the ability to Fetch, Pull, Push, and Refresh.


After all that was done. I went out to GitHub and downloaded a .zip file of the project, opened it and Unity, clicked the Scene and played my little first-person shooter demo. Everything seemed to work.

So I guess that’s a good start. There’s nothing complicated about my project setup so your mileage may vary, but if you’re just starting out (like I am) then this hopefully gets you up and running.