GitHub is a hosting platform for the version control system (VCS) that is Git. To work with GitHub you will need the Git software installed on your computer. Git is 100% free.
This story will assume you already have Git installed and have some basic knowledge about it. Also that you are intending to use it for your project. If you want to know more about Git and how to install it on Windows , follow this LINK to another post of mine on the subject.
- GitHub Account
Please make sure that you have a Github account. If you do not, head over to github.com and click on the Sign up button on the top right corner and follow the instructions to create your account. For more information on the account creation, head over this story I made about it.
Creating a repository in GitHub
To create a new repository on GitHub, first you will need to be already connected to your GitHub account then on the top right of any GitHub page you should have the + drop-down menu , where you can choose New repository.
Alternatively, if you are on the list of all of your repository,there is a green New button on the right.
Once on Create a new reposity page you will need to give your repository a name. It is best to choose a name that is relevant to your project. You can also add a short description about the project, but this part is optional.
You can also choose whether or not this repository will be public or private. This option can be changed later at any time. For now I recommend you to choose private if unsure.
Finally to complete the setup we will add a .gitignore to our repository. Gitignore is a text file that will filter out some unnecessary files and folders in our commits.
IMPORTANT: Make sure you select Unity as .gitignore template.
It is important to do so, because cache files may be huge and huge files are not really compatible with GitHub. More on that on another story.
Lastly you can add a license. You will need to informe yourself on which is the best suited to your project.
Once this is done, you can just click on Create repository.
Linking Unity project to GitHub
Assuming you already installed Git and you already have created a Unity project. To know how to install Git go HERE. To install and create your first Unity project go HERE.
In the Windows folder of the Unity project you want to link to GitHub, right click in the explorer and choose: Git Bash Here. The Git CLI should open.
Since you opened the CLI from the project folder, we don’t have to worry about navigating to it. This is probably the quickest way to get going but just in case you find yourself in a different folder you can utilize the cd command to change directory followed by the path you wish to navigate to.
Most Windows command line are working / Batch command.
Once you are sure your CLI is opened on the right folder. Enter the command
This will initialise Git in the folder. It will also add an hided folder name .git. This file will not be visible if your Windows Explorer configuration does not show hiden files.
Next go back your GitHub repository page. Once on your repository page, click on the green CODE button and subsequently click on the clip board icon to copy the address.
Back in our Git console we can now write the following command:
git remote add origin YOURURL
Note: Right click to paste the URL you just copied off the web, ctrl-v will not work here.
Now you can verify if the link is succesful by typing
git remote -v
And there you go. You succesfully link you project.
After that you can continue to learn how to use GitHub and Git by following this link to how to Commit, Push and Pull with GitHub.