Wednesday, April 15, 2015

Helpful Git Command Tips and Happy 10th Birthday Wishes

Helpful Git Command Tips and Happy 10th Birthday Wishes
Happy 10th Birthday Git!
This year marks the 10th birthday of git,  the distributed version control system created by Linus Torvalds who's more famously known as the creator of the Linux kernel.  If you're a software developer, I hope you're at least familiar with source control systems because they make your professional life SO much easier (though I admit they can be a bit challenging to first get accustomed to...).

Even if you're day job isn't in the software development space, my guess is that if you're in IT in any capacity, you've probably interacted with Linux or other open source software systems, most of which use git (and / or github) to manage their source code repositories.

Below, I've included a few helpful tips and tricks I've discovered to make using git even more productive for your daily workflow, along with links to learn more about the history of git and an interview with Linus on his take on git after it's first 10 years...


I was first introduced to version control systems for software source code via Microsoft's Visual Source Safe (I know, I know, it was a brutal beast to work with, but at the time I mostly developed Visual Basic & .Net applications and it was one of the few games in town...).

I used to wonder why other developers I knew working on "enterprise" software development projects used to rant and rave about how great source control systems were compared to the old days...

...until inevitably, I made some destructive changes to an application's source code and when I went to restore a backup of previous work discovered (to my absolute horror) that the backup system had developed some problem that had gone previously undiscovered.  After a frantic few days I came to the realization that the last good backup I had of the source code was over a month old and after re-coding over 4 weeks worth of changes made a resolution to figure out how to do this whole "version control system" thing.

Apache Subversion Source Control System
Admittedly, since I was new to the topic, it took a little getting used to.  But for the most part, I had to agree that knowing I could easily revert back to previous versions of my source code if needed made me both a better developer and much more productive. Of course, as anyone who has ever really used VSS for any length of time will tell you, it wasn't REALLY that great of a version control system.

After beating my head against the limitation of VSS, I eventually moved on to subversion (aka svn) and although it was markedly better than VSS (especially as I branched out to work on more non-Microsoft platform development projects) I did have to deal with the pain of merging changes manually for many years.

Thankfully, I soon discovered mercurial (hg) and later git and along with them the wonders of being able to (mostly) merge changes from multiple developers working on a shared code base with ease and simultaneously learning how much more pleasurable distributed version control systems were compared to their centralized counterparts.

So, as a sign of thanks to all of the developers who've contributed to git and in honor of it's 10th birthday,  here's a few links of helpful resources on git and it's history:

  1. Atlassian's Historical Timeline of git : a fun and interactive way to learn more about git and the major milestones in its development

  2. 10 Years of Git: An Interview with Git Creator Linus Torvalds : Published by linux.com, this interview includes some funny tidbits from Linus and the story of how he hacked the majority of it together on his own over the course of a week or so.

  3. 8 Small git tips : a short collection of helpful tips you can put into practice right now to make using git even more productive for your everyday workflow
One of my favorite tips included above is how to use the advanced features of git's log command to display the history of your repo in an easier to read format:

Using the advanced flags of git's log command to better format yrou repository's historical log
Sample output of 
git log --graph --decorate --pretty=oneline --abbrev-commit