Setting up Git for Unity3D

Ethan Bristowe
5 min readApr 20, 2021

--

Git is the most popular way for programmers to handle everything from small to very large projects through the use of the Git distributed version control system. It is vital for the sharing and saving of work done in Game Engine Programs like Unity3D, and thus is very important to learn the right way, how to use and set up Git for Unity.

Step 1:

Download and Install Git

Go to git-scm.com and download the latest build for your OS.

Once downloaded, open the Git Application and follow the Setup instructions. There will be a lot of prerequisite options they will ask you to choose from, ALL defaults options are ok, you may hit “Next” until it begins the installation.

Once you see this Window, be sure to leave “View Release Notes” unchecked, and then check “Launch Git Bash” and hit “Finish”.

Step 2:

Navigating Git

Now at this point you should see a very scary looking window that looks like this

Don’t worry, we’re not gonna hack any mainframes, it’s actually a lot more simple then you think. This window is basically your File Explorer, but with the functionalities we get with Git.

So we’ll start by typing “ls” (which stands for list) next to the $ sign, and you’ll see your files within the current directory which is displayed in the top of the window; MINGW64:/c/Users/____

What we are trying to do is direct Git to a Unity project that we want to make a repository for, so you can start changing directories by typing “cd” (which stands for change directory) next to the $ sign again, and then type in the name of the directory which will lead you to your Unity Project Folder.

Pro Tip: Just like in a code editor, you can press Tab after typing the first few letters of a Directory name and it will autocomplete it for you.

Here is a simple command list for navigating the directory.

If your Unity Project Folder can’t be accessed from the home directory that Git opened in, you can go to your File Explorer, right-click in the correct drive, and click “Git Bash Here”.

Once you have navigated to your Unity Project Folder, change your directory to the Unity Project you would like to create a repository for. You should be able to view your project files at this point.

Step 3:

Creating GitHub repository

Go to github.com, create an account if you haven’t already, and click on the “Create Repository” button on the left.

  1. Name your repository (should be the same name as your project)
  2. Select Public or Private depending on if you plan to share your project with others.
  3. Add .gitignore and select Unity as your template
  4. Click “Create repository

Step 4:

Linking GitHub repository to Project

Go back to Git and type “git init” to initialize a Git repository inside your Project File.

Next, click on the “Code” button in the Code Tab of your GitHub project page and copy the web URL.

Now, in Git, type “git remote add origin “ and then paste the link and hit Enter. You can type “git remote -v” and hit Enter to make sure that it worked, your Git should now look like this.

Step 5:

Commit!

Your Git and your GitHub are now Linked and set up with your Unity project! Now it’s time to make your first commit!

First we need to fetch our master branch by typing “git pull origin main”, hit Enter and if we type “git branch” we should our list of branches in which “master” should be the only one.

Next, we are going to take a look at the files in our Project that we want to commit, type in “git status” to look at our untracked files.

We can add each of these files one by one by typing “git add “ and then the name of the file you want to add to the commit, or we can add all of them at once by typing “git add .” Once you’ve done either of these you can type in “git status” again to see all the files you are committing.

Once this looks good to you, we can finally commit by typing “git commit -m “[type a message here]”” and then hit Enter.

Lastly, we just need to type “git push origin master” to see these changes in GitHub. You may be prompted to sign in to GitHub after you do this as well.

Congrats! You have officially set up Git with Unity!

--

--

Ethan Bristowe
Ethan Bristowe

Written by Ethan Bristowe

Passionate self taught game developer excited to learn and share everything I can about game development!

No responses yet