Foundations: Your First Repository

So, at this point, we’ve installed Git and Unity, we’ve set up a GitHub account and we created our very first Unity project. Now, we’ll link Git, GitHub and Unity together so we can tracking our changes.

Create a local repository

First, open Git Bash and navigate to your project directory. Check out my previous article for a refresher.

Once you are in your project directory, you will need to create, or initialize, your local Git repository. To do this, enter into Git Bash. From this point on, Git will track any changes to your project files within this directory.

git init command in Git Bash terminal

Link a remote repository

To be able to communicate changes between Git and GitHub, we’ll need to link our remote repository to our local repository. Log into GitHub and either create or open a new repository. Check out my article on Setting up a remote repository for step-by-step instructions on getting started with GitHub.

Once you’re in your GitHub repository, select and copy the URL provided.

Where to find the URL for your GitHub repository

In Git Bash, while in your local Git repository, enter followed by a reference name for the remote repository (traditionally ) and then paste the URL copied from GitHub above. The keyboard shortcut for pasting (Ctrl + V) does not work in Git Bash, so be sure to right-click and select Paste from the menu.

git remote add origin command in Git Bash

To confirm the link was created successfully, enter into Git Bash.

git remote -v command in Git Bash

Now that our local and remote repositories are initialized and linked, we’ll dive into the new way to save changes through Git in the next article.