Git-ing jiggy with it!
For those who are extremely interested in computers and tech in general have probably visited and/or used products and services hosted on GitHub. Being one of those people, when we had a speaker in, Joe Nash, to tell us all about GitHub, I was amazed that this service I’ve been using to play indie games was actually incredibly useful within the development of anything digital!
Git itself is a source code version control system created by Linus Torvalds, who also happens to be the creator of Linux OS. Being open source its freely editable by the public and available on the command line without any installation. It allows you to save versions of your project through commands such as commits, which basically creates a snapshot of your code at the time of the commit, a lot like saving a game. GitHub however is a website that provides a graphical web based interface where you can store these commits within repositories, basically a main project folder, which make your product or service accessible to the public to clone, edit and download and even collaborate.
Even though I’ve created several projects without using version control such as git, I felt it necessary to learn how to use this tool as it has had such a large impact on the digital industry. The aim of this project was to gain a basic understanding behind git and GitHub so that I can easily contribute and collaborate with professionals when I go into the digital industry. The main pull towards GitHub as opposed to other version control tools is the ease of use with a graphical interface so that everything is easily visible. The most useful aspect of version control such as git, is that if the project breaks due to an update, it can easily be rolled back to a previous state, therefore the project is rarely at risk of being seriously broken.
As for collaboration, GitHub allows people to create pull requests for the rest of the team to review and then push to the main product if the proposed changes work. If two people have edited the same thing, GitHub will also show a conflict for the developers to review and push the correct version into the master branch.
In order to learn GitHub, I chose to version control my other self-initiated project based on CSS Grid layout, found on this GitHub Repo. Using nothing but what Joe Nash taught me in a GitHub masterclass hosted at my University and GitHub’s own website, I was able to successfully achieve the aim of this project. The introduction guide on the GitHub website provided a detailed and concise run through of setting up a new repo and using the command line to create commits and clone requests.
The first step of any GitHub repo, is to create the repo itself so that there is a location for files to be stored. To do this I simply created a repo using the GitHub website and pressing the new repo button. Then, using the command prompt, I ran the command “git clone” along with the URL of my repo to pull the files to my machine and create a local copy of the project, followed by “git init” to allow git to monitor the folder for any changes.
From this folder, I was free to create and edit my files freely knowing that git would be able to notify me of how many changes ahead of the master copy on the repo I was working. Following this, I then created a ‘readme.md’ to create a note on the repo displaying a title and a brief description of what the repo was for. At the same time, I created a basic HTML and CSS structure to base my project from. The next step was then to push those new files to the master branch back on GitHub, using the commands “git add .” and then “git commit -m ’initial commit’” and finally “git remote add origin (URL of repo)” and then “git push origin master”. Following this I then went to check the repo to check whether any changes had been made, and fist pumped in celebration as it was a lot easier than I had initially thought!
Following my success with the console, I chose to try out GitHub’s desktop GUI to add the remaining changes for the project. As a safety precaution, I created a new branch, copy that runs alongside the master from which you can push changes to the master, called dev-branch-1.0 in order to sound more like a developer! I found the desktop app to be extremely easy to use after getting to grips with the console. It tells you how many changes have been made and how many items have been deleted from the files. Not only this but it gives you the ability to view each file as a text document with changes coloured in green and deletions in red, allowing you to easily see what’s been changed within the file. One advantage to using the GUI over the command line is that you are able to create pull requests which aren’t supported in the terminal.
Although I had a very brief knowledge of GitHub prior to this project, I found that I have gained an invaluable skill in being able to use it to its potential and even though I found it difficult to get to grips with the terminal at first, the guides produced on GitHub as well as their forums meant that if I ever got stuck the chances are that the answer I needed was rarely more than a few clicks away!