Integrating Git with Unity

Germán Walden
4 min readMar 27, 2021

--

Objective: Manipulate a Unity project repository with basic commands and be able to work with full control of it without risking to have any merge or conflict problem with another team member.

Requisites: Unity, Github account and Git App.

First of all we want to download the latest Git app following this link: https://git-scm.com/

Once installed we want to press right click on the explorer window inside of our Unity project directory and press Git Bash Here so we will initialize the git app inside of the root folder of our project.

Opening Git in the correct directory

At this point we want to initialize our git repository in the same directory with “git init” command, in my case it says Reinitialized because I have done it before.

Initializing our repository

If you don’t have a public repository go to your Github account and press the green button NEW on the upper left corner.

Important: Check .gitignore and select Unity to skip commiting unnecesary files to our repo.

Note: It’s important to see what name has your default branch, in this case we will use master, main is also okey.

Back into our Git app we want to link our local machine to our repo link by typing “git remote add origin + repo link”, you can find it pressing the green button Code on your repository.

To verify this we can type “git remote -v”

Succesfuly connected!

Now we verified that we are connected, there are 3 steps to follow to avoid merge conflicts.

Note: At any state of the workflow we can use “git status” to check if we are doing the process correctly.

Step 1: Pull from the repo.

We want to retrieve the information of our project to check it locally before commiting to the server. To do this we are going to type “git pull origin master”

Step 2: Commit to the repo

Checking the status in my case, it looks like I have nothing to commit, you should have red folders like Assets/, Packages/, etc…

To add a folder you can use the command “git add Assets/” to add the folder to our commit, you can check the status to see if the files were added correctly. To add all the files in our project we will type “git add .” Checking again the status should show you that everything is ready to commit.

Now we are ready to commit all the files to our repo using “git commit -m “Insert your message here””

Step 3: Push to the repo

Final step is pushing all the content into the repository. To make this we are going to type “git push origin master”

Well done! After all these steps we should be able to refresh the github repository on our browser and see all the content from our project uploaded there.

Important: Repeat this process every time you want to update your repository content to prevent any merge conflict

--

--

Germán Walden

Passionate Unity developer always looking for new challenges!