We’re going to start by creating a new Unity Project (or you can use an active project) that we’d like to connect to GitHub.
Next we’ll login to GitHub and create the repository we’ll be using for this new Unity Project.
When creating the repository, I like to keep the name the same as my Unity project (or at least very similar), to avoid as much confusion as possible. You can choose whether the repo will be public or private, completely up to how you want to share it.
IMPORTANT: When creating a repo for Unity, make sure to include a “.gitignore” file, and choose the Unity Template. There is a lot of information that doesn’t NEED to be on GitHub, and will end up jumbling your Git creating some chaos. The .gitignore easily solves this problem.
Voila! Your first GitHub repository has been created! It’s not doing much for the time being, so now we have to hook it up with our Unity project.
Open up Git Bash from your main directory folder of your Unity Project:
Luckily, setting up Git Bash to interact with GitHub is no circus act and can be completed in a few simple steps!
First: we have to initialize Git inside of the directory by typing “git init”.
Remember, when writing Git commands, every command is preceded by “git”.
Second: we’ll go back to GitHub and copy the HTTPS of our repository page:
This is what GitBash looks for when pushing to the server. It’s essential you copy and paste it with no errors!
Third: we create the remote server link, give it a name, and paste the HTTPS that relates to this new server. This is done by typing git remote add origin …
- git remote — is the type of repository. Not local (your computer), but a remote one (the server on GitHub).
- add — is telling GitBash this is a new repository.
- origin — is the name given to the repo. This can be anything you like, but it is industry standard for “origin” to be the repositories name.
- HTTPS link — this is the HTTPS you copied from GitHub. The server address where your new repository is located.
- when pasting the HTTPS into GitBash, you must right-click and Paste, or key-command “Shift+Insert”.
Now if all went well, you should be connected! You can verify this by typing “git remote -v”.
Next up, we’ll be making our first pull, commit, and push!