Setting Up Git and Github for use with Unity 3D

Bradley Yachimowski
6 min readMar 27, 2021

Git is a command line editor and Github is a repository server. Together, they create a version control system that allows an individual or a team to collaborate and maintain projects. These projects can be blueprints for a building, scripts for a screen play or movie, disaster preparedness plans for a response team and the list goes on.

In this article we will be using Git and Github to share our Unity Project with others for comments, edits and additions. So lets get started.

The first step is easy. Go to https://github.com/ and use your email to sign up for a free account.

Type in your email and click “Sign up for GitHub”

The next step is to go to https://git-scm.com/ and download Git.

Select the correct version for your operating system. I will be using the Windows 10, 64bit version. Begin the installation after the download completes. You will encounter about 11 pop up windows, simply click “Next” until you reach the “Completing the Git Setup Wizard”

Uncheck the “View Release Notes” and select finish.

Now lets go to the Github website. Sign into your account, if needed. It should look like the picture below.

Click “New”.

After clicking “New”, a “Create a new repository” window appears. Type in a name for your Repository. You can select “Public” or “Private”; if your not sure, you can always change this later. You can choose to add a “README” file if you wish, however, it is important to check the “.gitignore” block. Click the downward pointing arrow in the right-hand side of the block and add “Unity”. This prevents the hundreds of files common to the Unity editor from being shared. By clicking the “Create repository” button, we will create a “branch” called “main”. The “main” branch is like the trunk of a tree and from it other branches extend. For more information on creating branches, see the “Read the Guide” on the Github home page.

After we create our repository we want to access its URL, so we can connect to it from the git command line editor located on our PC. To do this, click on the green “Code” button.

Then click on the clipboard icon to copy the location of our repository's webserver.

Now we want to navigate to the location of our unity project.

From within this directory press the right mouse button and select “Git Bash here”.

This will launch the git command line editor in a new window in our Unity Projects directory. The git interface command structure can be confusing at first until you become familiar with the syntax. You can type “git- -help” to display the list of commands and usage.

Type “git- -help”.

Now we need to initialize our project. To do this type “git init”. If you look at your Unity project you will see some files that have been added by Git.

The picture above shows that git “Reinitialized existing Git repository…”. That is because I already initialized the repository previously. Your message will show “Initialized”, instead of “Reinitialized”, as in the above picture.

Our next step is to link with Github. (Make sure you are currently logged in to Github.) We do this by typing the command, “git remote add origin”, then paste the URL from your Github repository after the word “origin”; be sure to leave a space between “origin” and the pasted URL. If the URL is no longer on the clipboard, return to Github and click on the “green code button”. Then, click the clipboard icon to copy the URL and paste it after the word “origin”, as shown in the picture above and press the “enter” key to execute. The command, “git remote add origin”, adds a remote server named “origin”, located at the URL specified, (Github server) to our unity project. The name “origin”, is an industry standard label which simple means “the origin or source of our repository”.

Now that we have added our remote link, we can test it by typing “git remote -v”. If everything is correct, we will get a confirmation on our ability to “fetch” (pull) data from the origin and “push” data to the origin.

There is an order that must be followed when using a remote repository. We “pull” in the updates, “commit” our local changes, and “push” to Github. The first step is to “pull”. We “pull” the changes that other team members have made or changes you made on a different computer. We do this by typing “git pull origin main”. Remember that “main” is the name of our main branch on Github, however, within our Git command line interface it is called “master”.

Type git status

If we type, “git status”, it will show us the status of our files. Here we see all of our project files are “untracked”. We need to add these to our “commit” queue. To do this we can use the command, “git add <file name>” to add them one at a time or the command, “git add .” to add everything at once.

If we type, “git status”, we get the following list of changes to be committed.

The second step is to “commit” our changes. We do a “commit”, to select data to be pushed to the server. To do this we type “git commit -m “Created new Unity Project””. The “-m ” allows us to add a message that will be displayed in Github.

The first time you do a “commit”, you may be asked to identify yourself as in the above screen shot. Now that the “commit” has been created, we need to “push” the data to the Github server. To do this type, “git push origin main”. This send our files to Github.com, where the repository for our project exists, and adds them to the “main” branch, where they are available for the world to see or just your team. Now, if we go to Github, we can see our files in the “main” branch.

We have just completed the set up of Git for use with Unity. For more information on the full capabilities of Git and Github, check out the training sections on their websites and other locations online such as Youtube and Udemy.com. Good Luck on all of your future projects.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response