Mastering Git: the Githug Tutorial

Gabriella’s Journey
3 min readNov 29, 2017

--

Since almost the very beginning of my apprenticeship (since I’ve started implementing programs — as little as they could be — at least…) I’ve been using Git in my terminal to create repositories for my new projects and push them to Github.

I’m not a master of Git yet but compared to how I was when I started using it I feel I have made a lot of improvements! But of course there’s always something more to learn (and definitely, as I said, still I am not mastering Git.) Also, Git can be quite scary and confusing at times (who wouldn’t be scared if a single wrong command has the power to delete all your work??) Therefore today I started a Git tutorial (thanks to my mentors who suggested me to do that!)

I have already done a very basic Git tutorial some time ago (I’ve forgotten which one…) and have my very handy notes from it which I’ve consulted quite often, especially at the beginning. The tutorial I’m currently doing is Githug tutorial, “a practical way of learning git.”

Starting the tutorial is very easy. You need a command line and Ruby of version 1.8.7 or higher installed (the Github repo of the tutorial has a very clear README that helps you set up/install everything you need.) You then need to save the project in the desired directory and start the tutorial by entering githug.

You’re immediately prompted to answer a first question. If you can’t figure out the solution you can type githug hint in your terminal and get a hint (I understand you have more hints available, but hey, who is using the hints, not me… ahem…) If you’re stuck and want to reset the issue just enter githug reset. Once you’ve solved an issue you get a green comforting message (I love green…) and you’re ready for the next issue. Otherwise you get a terrible red message highlighting your failure. Red is not good.

My current Git knowledge doesn’t go much beyond commands like git init, git add, git commit. Or commands like git log, git diff (this is cool) or git diff --cached , to see changes when you’ve already staged them. I also quite like git commit --amend, which I’ve discovered just recently and am using quite often.

I can also handle branches with git branch <branch name> (creates a new branch), git checkout <branch name> (to change branch), git checkout -b <branch name> (creates new branch and switches current to new one), git branch -d <branch name> (deletes a branch.)

More advanced level is the Git command git rebase <current branch> which merges a branch into the branch where you are currently working, and moves all of the local commits that are ahead of the rebased branch to the top of the history on that branch (in another words, you can take all the changes that were committed on one branch and replay them on another one.)git rebase still makes me uncomfortable but I feel I’m making progress there as well. Also, turns out to be very useful.

The Githug tutorial has plenty of other interesting exercises that can improve your Git skills so I highly recommend it (although I’m still at half tutorial for now.) There’s plenty of other tutorials and very useful web pages in the internet, so don’t be ‘afraid’ to google whenever you need to.

But, most importantly, don’t be scared to try the newly learned Git commands with your project because there’s no better way to learn from experience (and mistakes as well.)

--

--