Setting up GIT For Unity

What is GIT

GIT is a version control system for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for source code management (SCM) in software development. SCM is the task of tracking and controlling changes in the software.. If something goes wrong, SCM can determine what was changed and who changed it. SCM is an essential part of modern-day software developer practices. Between collaborating with a team working on different aspects of the software, being able to revert back to a known good working copy when something goes wrong, or to keep development from final release.

One of the common combination of tools that we have to use as a Unity Developers for SCM is GITHub and GIT.

How to install GIT

First go to https://git-scm.com/downloads

Downloading GIT

I am using Windows so I am going to download the windows version by clicking on Download 2.31.0 for Windows.

After Downloading GIT run the installer, no need to make any changes to the defaults, just accept the user agreement and click next until it starts installing.

Integrating GIT GITHub and Unity

Go To https://github.com/ and log into your account, if you do not already have one create an account. On the left hand side of the screen Click on the New Button next to the word repositories to create a new repository.

Give your repository a name and a description.

Make sure to click the Add .gitignore and choose Unity from the drop down list. Feel free to also add a read me file and choose a license if you want, these are not required.

https://i.imgur.com/YRixpwC.png

Then Click the Create repository button

https://i.imgur.com/VA8MVYH.png

Now Create your Unity Project.

https://i.imgur.com/UQD4DYR.png

Once your UNITY Project has been created right click on the Assets Folder and select show in explorer. This will open a window where your Unity Project is Stored.

https://i.imgur.com/84rD3ss.png

Right Click and select Git Bash Here, this opens the command line prompt for GIT.

https://i.imgur.com/nWeQdSK.png

Now you have to initialize GIT and link the repository. The first command that you need to type is git init

https://i.imgur.com/UXhCnJv.png

Now in your GITHub repository (the one we created early on the internet) select the green Code Button. Make sure HTTPS is underlined (if not select HTTPS). Then click on the clipboard icon which will copy the link to your repository.

Now in the GIT Bash console type git remote add origin

Then right click and select paste.

Then hit the enter key this will link your GITHub repository to your GIT and your Unity project folder.

https://i.imgur.com/s0riavu.png

Now verify the repository with git remote -v

https://i.imgur.com/RkS2GuG.png

Now we need to Pull the main branch, git pull origin main

https://i.imgur.com/NKNK4NA.png

Lets check the status of our repository, git status

https://i.imgur.com/vwcrDQY.png

It looks like we have untraked files (all the files listed in red) and nothing committed to the repository. Let’s add all of the files to the repository, git add . don’t forget the period after add. The period indicates that we want to add all of the files. Now we will see a bunch of warnings about LF (line feed)which is normal as GIT is converting all of the line feeds.

https://i.imgur.com/EJyXHrG.png

Now lets Make a Commit with a message, git commit -m “Message” i.e. git commit -m “Initial Commit with new Unity Project Created”

https://i.imgur.com/GA7rINp.png

Now lets push our project back to the repository, git push origin main

With everything Done our repository on GITHub should now contain the newly created UNITY project.

https://i.imgur.com/ve83EUw.png

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
James Lafritz

James Lafritz

Excited about changing my hobby into a new carer with GameDevHQ course.