Using GitHub with GameDevHQ Certification in Unity
As I am completing the first part of the 2D Game Development Course, created by Jonathan Weinberger of GameDevHQ, there were 3 challenges I faced in using GitHub in preparation to receive my GameDevHQ for Unity Certification. I’ve written this blog post with the hope it will be found useful by others going through GameDevHQ’s world-class training in Unity.
#1 — GitHub has recently changed their default “branch” from MASTER to MAIN. If you are freshly installing the command line tools from the GitHub website, you will be fine and should not experience this road block.
In my case, I have a few dozen repositories that use MASTER, as that has been the default, so my computer’s GIT library defaults to MASTER. To solve this, all I have to do is “git branch -m master main”, which will move everything in MASTER to MAIN.
The point here is that as you go through Jonathan’s training videos, just use MAIN wherever he uses MASTER.
#2 — When I did my first “commit”, I had made the mistake of not changing two things that caused the size of my repository to grow above 100MB, the limit that GitHub sets for repositories you can push (upload) to their servers in the free account. To solve this:
A) after you’ve created the repository on GitHub and setup the .gitignore file to include the Unity settings, as Jonathan explains, I recommend you edit the file online in the GitHub site itself and add these lines to the “.gitignore” file, as you should see many of the existing Unity settings and add these to it:
/[Aa]ssets/GameDevHQ
/[Aa]ssets/GameDevHQ/
/[Aa]ssets/GameDevHQ*
NOTE: The filename does have a period as the first character. This typically keeps it hidden.
B) While still in the GitHub site, click on the GREEN CODE button, and then click copy to get the URL where you see https. This is important to keep and save as we will paste it as the repository URL down below.
C) move the macOS (or PC windows) builds and the webGL builds you created, as instructed by Jonathan, into the Builds folder. This is required to make sure GIT doesn’t try to include these large files in your Git repository. If you fail to move these folders into the Builds folder, you’ll end up stuck, as I was, with a repository larger than the 100MB limit set by GitHub.
It’s important to note that once you’ve made either of these mistakes above, you will be unable to keep your Git Repository below 100MB, because a repository keeps all files, and all changes. The only way to proceeds if you make these mistakes will be to remove the .git folder from your project folder, delete your repository on GitHub and start over with a new repository entirely.
#3 — here are the simple steps to get it right after you have gone through the GitHub Crash Course and have installed the GIT command-line tools.
A) After you create the repository on github.com, just as Jonathan teaches us to do in the training videos, be sure to add the Unity settings for .gitignore as written in 2A above.
B) Be sure to install the GitHub command-line tools and then change to the directory/folder of the root of your project. You’ll know you are there if you type “pwd” and see that your current directory/folder is your project folder, otherwise you can use “cd” to change the directory/folder until you have the prompt inside the root of your project directory/folder.
C) After you have made sure the macOS (or PC windows) builds and webGL builds are in a Builds folder, you can now create the local repository by typing:
git init
You will then connect it to the repository URL that you copied in 2B above and type:
git remote add origin REPOSITORYURL (example: https://github.com/xxxx)
To continue as Jonathan teaches in the course, next we will verify the remote repository by typing:
git remote -v
Next, we will PULL (download) the remote repository on GitHub by typing:
git pull origin main
Next, we will see what the default branch is for this repository by typing:
git branch
If the current branch is shown as “MASTER”, and ONLY IF IT SHOWS “MASTER”, will you type: git branch -m master main
The next step will be to add all the files of your project to the local repository by typing “git” space “add” space “.” as follows:
git add .
Next, we will see if the add worked. Type…
git status
We’re almost done, now. The next step will be to, as Johnathan teaches, to move our “staged” files to the repository using “commit”. Type:
git commit -m “First Commit of My GameDevHQ Unity project”
Now that our local repository is prepared, the final step now is to PUSH (upload) our changes up onto the remote Github repository as follows:
git push origin main
Well, that’s it. I certainly hope this blog post will be of benefit to some of you. Feel free to send me any suggestions for improvements. Hopefully, you’ll be able to submit your project to GameDevHQ to complete your 2D Game Development Course Certification in Unity.