Day 1: Setting Up Git for Unity! Working with Commits and Branches

Alex Frankovic
3 min readAug 10, 2022

--

Objective: How do we utilize Git and its features when working with a unity project?

When we begin to work with our unity project, we want to make sure that Git Bash is our natural best friend. Whether that is working with branches and/or commits.

When we begin to open up a brand new Unity Project, we want to be able to link it it to an origin server. In this case, we will be working with GitHub as our main origin. In order to do this we need to create a Github repository and be able to initialize it. After initializing it, we want to add its origin.

Linking to our origin server

After successfully linking our project to the origin, we can begin to play around with some commits and branches. For every piece of work we contribute to our project we want to create what is called a commit. To create we want to follow three direct steps in doing so which include pulling from the server, commit, and then pushing.

In this case, let’s say I added a C# element to my project. After adding this piece I want to create a commit. So by following our steps, we first want to pull from our origin into the branch we are working (master branch in this case). Then we want to create a commit followed by pushing to the origin itself.

3 simple steps to a commit

Finally, working between branches in our Git: This helps us break down specific aspects of a project. Using branches helps break down the workload of a project when working with a team. Let us take a look.

We can break down a project into sections whether its working on a story, RPG elements, inventory, etc. To do this we simply want to go into a our git and simply type “git branch” and then whatever we want to name our new branch. In this case we will name the new branch RPG elements. We can then view all our branches that we have created.

Creating branches under Git

Once we have our branches, there are other things we can such as switching between branches using “git switch (name of branch).” We can also merge the work we do in our branches by using “git merge (name of branch).”

--

--