Road to Game Dev: Git, Unity, and You (Part 2)

Rowan Mcmanus
4 min readMay 7, 2021

Setting up Git with Unity

Now that we know how to navigate Git, we’re actually going to leave Git alone for a moment and go to: https://github.com/. Create an account if you don’t already have one, and then create a new repository:

Make sure you give it a recognizable name and description, and change it to a “Public” repository if you plan to show it to anyone else! You also want to make sure you have these settings checked:

This will tell Github that this will be for a Unity project, and let it know to ignore most of Unity’s default files, since you won’t actually be changing those. Now it’s time to go back to Git Bash! Go ahead and open up the Git terminal, and navigate to your project folder. Now comes the real meat: Use the command “git init” inside that folder to tell Git to initialize this folder as a Repository. Grab the Github URL for your project:

The command “git remote add <name> <URL>” will tell Git where to go to actually sync your files. <name> will almost always be replaced with “origin”, and the URL is whatever you copied just prior — make sure to remove the angle brackets! Then use “git remote -v” to verify that it worked.

Syncing Changes to your Repository

You’ll start to see a couple of key terms thrown around now: “Push”, “Pull”, “Fetch”, and “Commit.” Let’s start with “Fetch” and “Pull”. If you’re working on a project with other people, these are the two most important terms. “Fetch” is a way to ask the server what file changes there are. and “Pull” will start by Fetching and then merge any of those changes with your current project folder. You always want to Pull before making changes to the main project to make sure that anything your teammates have done doesn’t get erased! It’s a good habit to do this even for personal projects, too.

In order to actually make any changes, you need to set them up. Making a change to the main project is called making a “Commit”, committing your files to the main folder. “git status” will tell you what’s been changed, and what’s ready to be comitted. “git add <folder>” will tell Git to commit that folder, and “git add .” will add everything!

From here, you can use “git commit -m “<your message here!>”” to finalize all those commits! -m allows you to add a description as well, which is incredibly useful for keeping your team members up to date. However, “committing” a change hasn’t actually sent it out yet. All you’ve done is tell Git that these are what you want to finalize. In order to actually push those changes to the master project, you have to, well, “Push” them. “git push origin master” will push those changes out to the master branch of your project — that’s when everyone else will be able to see it!

Every time you make a change to your project, make sure you do all three major steps. Pull, Commit, and then Push. You’re now ready to make changes to your projects!

--

--