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 git init into Git Bash. From this point on, Git will track any changes to your project files within this directory.
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 Code and copy the URL provided.
In Git Bash, while in your local Git repository, enter git remote add followed by a reference name for the remote repository (traditionally origin) 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.
To confirm the link was created successfully, enter git remote -v into 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.