Installing and Linking Git / GitHub with Unity

Version control, it’s a wonderful thing. With code and assets it is very much a need in game development. Without it, keeping track of changes and collaborating can result in a tangled mess of files of questionable origin and function. Version control allows the user to comment with each change that is committed and form a ‘chain of evidence’ that provides developers a map for a file’s history of work and ownership and allows for the removal of, things we would rather never have done. Two of the most common tools in this field are Git and GitHub.
To start, you’ll need Git. Just go to https://git-scm.com/ and download the version for your OS. For this article it will be Windows 10. Choose the default settings for all options. Once that is done, go to GitHub, https://github.com/ and create an account there, assuming that you do not already have one.
After completing those two steps you will then want to create a repository for your Unity project in your GitHub. Go to GitHub and start by clicking on “New.”

On the next screen you will make some decisions about the name, visibility, and other details of your project. You will give your project a name. Then you will decide whether it is visible to others. Working alone you could go with Private, but if you want to collaborate with others, have a team, or your displaying work for job applications, you will go with Public. Also, specify a .gitignore file. With Unity there will be a lot of extra files that are not relevant to your project and do not need to be tracked for version control in GitHub submissions.

Finally, you will link your Unity project to your newly created GitHub repository. Start up Git Bash, the command line version of the application, and navigate to the directory where your files will be living on your local machine. You do this using the ‘cd’ command, same as you would on most other command lines. Once there you will ‘initialize’ that directory by typing into the Git Bash command line ‘git init’.
You will then enter ‘git remote add origin’ and the URL of your repository on GitHub plus ‘.git’. For mine it looks like this…
git remote add origin https://github.com/dclrocks/unityLinkingExample.git
To break this down, ‘git remote’ is the initial command that gets git’s attention. ‘add’ tells git what it is about to do. ‘origin’ is the alias that will represent your project’s URL in the future. And, well, there’s the URL of your project plus a ‘.git’ on the end of it to tell git where it is going to go to do all of this…’git’-ing. When it is all done, you can type in ‘git remote -v’ to see a verification of the link that has been made. You will end up with something like this…

Now your project is linked to your local directory and work can begin.
The next article will cover basic commands in git and their various functions. Till then.