Get your Unity project set up with Git & GitHub (Mac)

Getting your Unity projects set up with version control is super easy and worthwhile! There are many options, but in this post, I’ll outline how to set up with git and GitHub on a Mac, using GitHub Desktop for ease.

Step 1: Set up a Unity project if you haven’t done so already. Otherwise, move to Step 2.

If you are starting your development from scratch (like me in this guide), create a new Unity project in your preferred file location.

Create your Unity Project and click “create” after completing the starter project info, project name and location path.

This might look different for you depending on whether you’re using Unity Hub and the version you’re running on

Give Unity a few mins to do its thing.

Once done, you should see your project files inside of your new folder.

Step 2: Install Git.

If you do not have git installed on your machine, you’ll need to get it.

For Mac, you can download from the official site or use brew.

https://git-scm.com/

To install with brew, open Terminal and type this command:

brew install git

After that is finished, we’ll use a nice easy GUI instead as you’re likely new to version control.

There are several GUI clients you can use, including Sourcetree, GitKraken and many, many more. We’ll use Github Desktop, which is quite popular and simple to use. I like how clean it looks.

Step 3: Install Github Desktop

You can download from the official site or use brew.

Go to https://desktop.github.com/ and download or to install with brew, open Terminal and type this command:

brew install --cask github

After installation is complete, you should be able to open GitHub Desktop in your applications.

What Github Desktop looks like on first open

Step 4: Make a repository on Github.

Sign in directly using the “Sign in to GitHub.com” button below. This should direct you to a login window on your browser.

  • If you have a GitHub account, simply log in.
  • If you do not have a GitHub account, you can create one for free.

Leave this setting and click “Finish”.

Create a new repo on your hard drive as below.

Name it the same as your Unity project and in “Local Path”, make sure to list the parent folder that holds your Unity project.

IMPORTANT: From the Git Ignore dropdown, select “Unity” if you want to ensure you are excluding certain Unity files in git. You can learn more about what a .gitignore file does here.

Before repo is set up
After repo is set up

LFS is just large file support. You can allow, but we are using a .gitignore to avoid huge commits.

Click “Publish repository”.

If you want your repo to be private (by invite only), make sure to keep “Keep this code private” ticked.

If you click into the folder, you would have a .gitignore file and some other essential git configuration files created.

If you click COMMAND + SHIFT + ., then you should see those hidden files in your folder.

Anyway, this is getting off track but just good confirmation that things are all set up as intended.

Step 5: Check that your project repository has been published on Github.

Go to Repository -> View on GitHub.

You should see all your project folders and files (aside from those in your .gitignore) in your remote repo now!

If you were to create, modify or delete any files in Unity now, the changes will appear in your GitHub Desktop client like so! Here I made a new script to handle Player Movement.

(Note: Unity will often modify some Project Settings as you can see below too).

Add a commit message that describes your file changes and click commit to main.

After you commit your changes, you need to push them so that they are visible online.

Now when you have a look at your remote repo, you should see only those newly pushed changes to your remote repo.

Done!

If you are going to work with collaborators on this Unity project, always ensure you regularly fetch + pull before committing + pushing files to avoid conflicts. (Also, great communication between who is working on certain assets or scripts is always very smart!)