What is this “GitHub” of which you all speak?
Last time I blogged, I promised that my next post would be about something technical and it sort of is…9 months ago, I started writing the following story…
Truth to tell, I feel slightly embarrassed even asking this question as it seems like something I should just know. But ignorance is not the same as stupidity and failing to go forth and find out would be the stupid option in this scenario.
However, I do have to admit that the name made me giggle slightly immaturely. I don’t know if this is the case in anglophone countries across the globe but here in the UK, if someone is a “git” it means they’re a bit of a tosser. Sometimes it’s even used affectionately (don’t ask me why). So I got this mental image of a hub of gits hanging out…also up North, we use “git” to mean “really” or “very”, so for example Cheryl Cole might say “Eeee, these falsies are git big like, a’n’t the’?”(Translation: “These false eye lashes are really big, aren’t, they?”).
But I digress. In the past week alone, 3 separate people have told me to use GitHub, all for totally different purposes.
1. I wanted to show my mate Martijn the adventure game I’d been working on in Codecademy but to do this, he would have to log in with my username and password which he seemed unwilling to do (though I wasn’t sure why exactly — what did he think he would get up to? Run renegade and correct all my exercises? Yes, yes, I know sharing passwords is generally a bad idea…) and he suggested GitHub.
2. Women Hack for Non Profits asked me to share my blog posts with them on their wiki, but it seems like I have to have GitHub to do this.
3. I was asking my boyfriend (who blogs too! You can check out his page andrewingram) what the best way was to copy and paste bits of code on here and once again…GitHub. I was working on a post about objects which will now have to wait until I’ve got GitHub down.
So, without further ado, let’s check it out!
[Goes to check out GitHub]
Um. Ok. Errr….
Still feeling a bit in over my head to be honest. I created an account and checked the About page. But they’re going on about repositories and I only have a dim idea of what these are. Maybe I should try creating on
Well, I did. In fact, I have created lots of repositories since then. But then got so busy, I never got round to finishing this story. However, I thought it was worth coming back to because actually, to the uninitiated, GitHub seems pretty confusing at first.
So, what is GitHub? Anyone in the know will tell you that it is a version control system (embarrassing confession: when I first heard this term, I thought it was ‘vision’ control and got extremely confused). But what does that mean, exactly? Well, imagine you are writing a novel. You send it to a friend to read over. In the meantime, you decide you want to change the last chapter to turn your romance into a tragedy. Then your friend sends you the first version back and has edited it to correct manifold spelling mistakes and has also included a note of some suggestions. So you then have to copy and paste the last chapter into this new version. And then you start rewriting, based on your friend’s suggestion….if you’re savvy, you will keep all versions of your story and name them something like v1, v2, etc. So that if you decide it was perfect to begin with you can just go back to the first version. However, you will end up with a potentially confusing mess of lots of different versions littered around your folders. Version control helps to clear this up. Every time you make a significant change, you ‘commit’ it and then keep on writing. In your repository (which is essentially just a folder in which you have initialised version control), you will only see the one version of your document that you are currently editing but if ever you want to return to a previous version, you can do so. I don’t intend to get into the whys and wherefores of how to do as it is beyond the scope of this post (and it will differ depending on which version control system you use) but hopefully you now understand what it is useful for and why it is used. When you are using GitHub, you will have a copy of whatever you’re working on in a repository on your computer and, provided you make sure your changes are updated regularly, on your account on GitHub. Everything you save to GitHub is stored in the cloud, but not only this, other people can read it, copy it to their computer, make edits and send these back to you among other features.
Version control is especially necessary when writing code because the smallest change can break your code completely and cause it to explode in your face. At such times, it is great to be able to go back to the last point in time when it worked and start again. Also, it allows users to collaborate on projects together as it keeps track of all the changes each individual makes.
Which brings me back to my friend Martijn asking if I could post my code on GitHub. Which I did and meant that he was able to download the file onto his own computer, whack it between script tags in an html document, open it and play my adventure game (code here if you’re that interested — disclaimer, it is terrible code, but it does work). Which was indeed a much better solution that giving him my Codecademy user details…
As for sharing my blog post on the Women Hack for Non Profits wiki, the reason for this is that WHFNP are hosting their wiki on GitHub. Therefore it comes under the definition of a shared file to which I can contribute (as a side note, you do get to decide who can and can’t contribute to projects on your GitHub profile) — and so I did and you can find a link to this very blog here.
Finally, as a way of creating and embedding code snippets in a blog post, I must admit that up until yesterday, I still had no idea how to do this…but today I made it my challenge and voila!
In fact, it really wasn’t that hard and I can’t believe that I put it off for so long. What you do is create what is known as a ‘gist’ on your GitHub profile (some helpful directions for how to do that here) and then just copy and paste the url into Medium, hit return and BOOM! Code example at your fingertips. I think for other blogging platforms, you may need to put this between script tags, so do double check.
And there we have it…9 months in coming (I mean, you could have a baby in that time) but hopefully you now have a better idea of what GitHub is and how it can help you.
Until next time!
If you like this post, don’t forget to recommend and share it. Check out more great articles at Code Like A Girl.