My experience with version control and Unity so far has primarily been through GitHub Desktop, and I’ve generally found it to be pretty accessible and user-friendly. My teammates at eargym can get themselves set up and working with it pretty quickly, whether they’re sound designers, game designers, or artists. I’ve avoided using the command line for some time now, only ever really delving into it when things go particularly wrong (and we need to, say, revert back a couple commits or undo a commit to the wrong branch).
Taking a module at GameDevHQ on the subject was incredibly reassuring, and has taught me a lot about using Git Bash to navigate directories, create repositories out of pre-existing Unity projects, changing branches with git checkout (or git switch), merges, and the general workflow of pulling, committing, and pushing. While the concept of many of these wasn’t unfamiliar to me, the specific commands and syntax of git is something I admittedly haven’t had too much experience with. I’m going to make it one of my aims with this course to use the command line in place of GitHub, if only to build up some more experience with this and keep what I’ve learnt fresh. I did make a couple of mistakes on my local files, but a couple of searches and Stack Overflow articles helped me undo them before they got pushed.
To recap, on making a new commit:
- git pull origin [branch name] // to make sure the local branch is up to date with the remote branch
- git status // just to check which files need to be tracked
- git add . // to track those files
- git commit m- “Commit Name” -m “Description” // (with optional description)
- git push origin [branch name] // pushing these changes to the remote branch.
One of the particularly invaluable skills I learnt from this module is in using hash codes from previous commits. We can use git log to view the commits on the current branch, and then we can use ‘git checkout [hash code]’ to revert to the branch at the time of that commit. This definitely seems like one of the more powerful features of version control. I’ve also learnt we can go back by, say, one commit by using ‘git reset —hard HEAD~1’. And lastly, I’ve learnt that we can then create branches based off these previous commits using ‘git checkout -b [new branch name] [hash code]’, as well as how to reset the project to a previous state (but only should you absolutely have to).
I’ve taken some more notes on this module and am hoping to check out some of the chapters of their C# Survival Guide sometime soon (mostly to fill in some gaps in my knowledge).