Ready, Set, GIT!

Michael Bartosh
5 min readApr 24, 2021

Part III — Save Git for Later

This article covers the creation and setup of a Git repository on both GitHub and on your local computer. I will address how we then link the two of them together so that when we make changes in one, we can reflect those changes in the other one.

Photo by Markus Spiske on Unsplash

I will be assuming that you are working with UnityHub as your development platform on your local machine, although you could be using any other development platform using an Integrated Development Environment (IDE) of your choice.

The first step is to create a project that will be the base for your development efforts. For the sake of this article, we will create a Unity project using UnityHub in a file directory we have pre-allocated and named (i.e. UnityProjects on our desktop). This folder will be used for all of our Unity projects going forward.

New Folder Created to Store Unity Projects

Now we will use UnityHub to create our new project…

Click the “NEW” Button to Create a New Unity Project

Select the folder we just recently created to store our project source code and resources.

Name Your Project and Select the Folder We Created Earlier

Press the “CREATE” button and Unity will create the new base project.

Once the project is created, you will see the new Unity project that we just created.

New Unity Project

Close the new project and then we will navigate to our UnityProjects folder to continue.

Our UnityProjects Folder

Open GitHub in your browser and sign-in (www.github.com/login).

GitHub Login Screen

Create a new Git Repository by clicking the New button (circled in the following screenshot.

Online GitHub Repository Manager

Give the new repository a name appropriate for your project. Set it to “Public” for the purpose of sharing it with others or “Private” for designating it for yourself and other team members. (We show it as “Public” here for the purpose of sharing it with our development group). Then add a “.gitignore” option specifying “Unity” from the dropdown list options. And finally, click on the “Create Repository” button.

Settings for a new Repository

A new GitHub repository will be created shortly and open to the following screen.

Initial GitHub Repository

Now we have to link this central repository to our local machine’s project.

Click on the Code button and then click the “Copy to Clipboard” option that is pointed at by the red arrow. This will enable us to paste it later when we link this repository to our local version of the repository.

Click on the Copy to Clipboard Option

Open the GitHub Desktop application on your local machine.

Click on the “Create a new Repository on your hard drive…”. Then fill in the Name using the same name as the one you used on the central GitHub master website. Then “Choose…” the directory where you initialized your original Unity project. Finally, click the “Create repository” button.

Create New GitHub Respository

After a relatively short period of time, the repository will be created and the following screen will be displayed.

Created Repository

Start up Git Bash and navigate to the new repository on our local machine.

Navigate to the new repository location on our local machine

Now we need to connect the central GitHub repository with our local repository using the following command:

git remote add origin <URL>

where we paste in our original URL that we copied earlier into our clipboard, then press the enter key.

Link the two repositories together

NOTE: You may be prompted to login to GitHub again for security verification purposes.

At this time, we can verify our two repositories are connected correctly by entering the following git command:

git remote -v

You should see the following response after pressing the enter key.

GitHub Verification

The 2 lines which are displayed show the origin name as the remote URL we pasted into the previous command to link the repositories as well as to show the available actions (fetch and push).

Congratulations! You have successfully linked your new repositories!

Next, we will look at Part IV — Check Git Out! where I will cover the process of maintaining a Git repository through the provided options of Git Bash, the command line interface to GitHub, that we began discussing in this article.

--

--