When I first began to teach myself how to write computer programs, the computer I had was a Radio Shack Model III with no disk drives, no hard drive, and only 16K of memory. That’s not a typo…it had 16,000 or so bytes of memory and that was it. When the machine was turned off, any code you had written was lost as there was no way to save it. I eventually added the ability to save data via a cassette recorder. If you listened to the cassette tapes in a regular player, they sounded exactly like the sound you hear from a fax machine over the phone. I learned to code in BASIC. I figured out pretty quickly that I had good logic skills and I understood how to get the code to perform exactly what tasks I wanted it to.
Years later (but still before Windows was a household word), I learned to use Visual Basic for DOS to create inventory and sales reporting software for my family’s company. That code ran well into the 90’s before the machine it was installed on had to be replaced. I eventually moved into the modern age and began coding in a more recognizable version of VB, as well as PHP, ASP, Clipper, and many other development platforms. I wrote one of the first internet programs for Real Estate database engines in ASP, VB, SQL, and HTML for private use by agents in the late 90s/early 2000s.
Then I decided to become a teacher. I hoped this would allow me to travel around the world and visit far away places for more than just a long weekend. And it worked. I taught math and physics in China for a short time. But I never got over the thrill of creating software — basically something useful from just code. So, recently I came back.
Today, as I begin my journey back into the world of computer programming (specifically game development using Unity 3D), I am on a MacBook Pro that has an SSD hard drive, using state of the art development tools. Unity 3D is my tool of choice for developing and coding games. I have a lot of new things to learn and I will be documenting that process here as I create my portfolio that I will use to showcase my games and applications created along the way.
The first step is to learn to use Git. A tool that can not only safely store backups of projects like a time machine, but allow users who work in large teams to manager the version control necessary when multiple people work on the same project.
Using command line version Git on a Mac is essentially the as it would be on a PC and installing it was simple. Just head over to http://git-scm.com and it will guide you to the correct download based on the operating system you are currently using. They do a really great job of walking you through the installation steps, so I will not repeat those here.
Once you are in the terminal window, a few good commands to memorize are ‘help’, ‘ls’, and ‘cd’.
- The help command does just as its name suggests — lists the help menu.
- ‘ls’ is short for list and gives you a list of all the files and directories in the current directory.
- ‘cd’ is short for ‘change directory’ When used by itself it will move you up in the directory tree. When used with the name of a directory located in your current path, it will move you into said directory. I’ve gotten into the habit of enclosing my directory names with quotes as some have spaces in the names while others do not.
The first step when implementing version control in your project is to, well, create the project! I created a simple Unity project called ‘Version Control’ for this article.
Next, I’ll make a repository for the files on Git Hub.
And now you have a few options… I highly recommend adding an ‘ignore list’ for Unity files that do not relate to our project and would just be clutter. Luckily, there is a very easy way to do just that!
Now we have our first repo on Git Hub. This is so cool!!
Now let’s link the project on our computer to the repo we just created so we can begin to implement version control as we build the project.
The steps to do this are:
- Create project on your machine
- Create initial repository on Git Hub
- Using the command line, navigate into the directory where you project is saved on your computer.
- Then type ‘git init’ to initialize git.
- Type ‘git remote add origin path_of_repository’
- Then to verify, type ‘git remote -v’
Easy enough, right? Now your project is linked to the repository and you can…what? What does all those commands in the second bullet point mean? Ah, sorry — so excited I almost rushed past the explanation.
‘remote add origin path_of_repository’ means that you are connecting to the remote repository and giving it the name ‘origin’. You could use a different name, but that is the industry wide standard I believe. The path_of_repository can be copied from the repository itself by clicking the CODE button and then the tiny clipboard (see image below).
Now we have everything connected. Next time I will show how the repository registers changes and keeps your versions separated just in case a new idea for a feature in your program or game does not work as expected. Rolling it back is easy!