Pre-course week 1 – let’s Git it on

After becoming acquainted with the command line, we were introduced to another new friend this week – version control. Now version control may not immediately ooze sex appeal, but from what we’ve learnt so far it does appear to be pretty fundamental in getting past first base as a developer.

In a nutshell, Git is the most widely used version control system favoured by developers all over the world. It allows users to take snapshots of projects/filesystems as they stand at any moment in time, lets you branch out into parallel universes and miraculously revert back to previous milestones with relative ease. In short:

IT’S A FREAKING TIME MACHINE.

Now tell me that doesn’t stir something inside you?

Incredibly, most of what you can achieve with Git can be achieved on your local disk. This is absolutely mad. Almost instantaneously, you have access to the entire lifespan of your project – creating, developing and destroying its parallel universes with a couple of keystrokes. How is it all stored in there? Where is it all hiding? Sorcery. Probably. (Note to self: research actual answer)

However, there are many occasions where developers don’t want to squirrel away their code and in fact want to share their projects with other coders. This is where GitHub.com comes into its own. GitHub allows you to ‘fork’ a project from another user, make changes to your copied version, then merge both back together using a ‘pull request’. This is pretty handy when you think about it – multiple people can make changes to different parts of a project simultaneously then piece the whole back together.

Completing the week’s challenge allowed us to flex our Git skills and push our first project to GitHub. We now all have a couple of ‘green dots’ to our names – wahoo! We were also directed to this super awesome tutorial, which I totally recommend to anyone just getting started. There are so many great tips and tricks that make moving around with Git that much easier, like this vision-saving log format suggestion:

Screen Shot 2016-07-24 at 11.49.16.png

Using this ‘–pretty=format’, we are very conveniently provided with the abbreviated hash of each commit, when they were made and a bit of detail about each one – all in logical ASCII graph layout.

This is so much better than the standard print out for git log, but a bit of a bugger to have to type out every time. Luckily, the tutorial takes you through how to add whatever shortcuts take your fancy to your .gitconfig file – and just like that my new ‘git hist’ command is my everything. Furthermore, tagging ‘–all’ onto the end of it gives you a great little representation of all your branches (and whether or not they have been merged yet) which I’ve found really useful:

Screen Shot 2016-07-24 at 12.37.39.png

One more thing I thought was really cool is the ability to amend previous commits using:

git commit –amend -m “comment

Screen Shot 2016-07-24 at 12.13.57.png

Here you can see that my original commit for “Add an author comment” was completely replaced with the amended version “Add an author/email comment” and doesn’t appear in my Git log. Bearing in mind this is my first shock exposure to all things Git, I have absolutely no doubt that this will come in very handy.

Overall, it’s been a great first week – I feel I’ve learnt a lot about some of the most fundamental tools for developers and had fun doing it with my cohort! Now onto week number two… when the real coding begins!

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s