Git Intro

15 Sep

Episode 35

Since last time I finally showed you some code and mentioned storing examples on GitHub, let’s talk about underlying version control system and surrounding tools. Many of you probably used SVN as version control, especially if you worked for big corporation which are not that fast at adopting new stuff. Some of you perhaps switched to Git, maybe after leaving the corporation for smaller and smarter company. Well, that would be me right now :)

The System

logomark-orange2x“Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency” says the homepage.

Git is distributed. Everyone has his own copy of the repository on a local machine. You can commit to it and fall back to earlier versions without relying on central server as in SVN. What about the Holy Trunk then? In typical workflow there is a base remote origin repository, where all changes are pulled, acting more or less like the SVN server and source of truth.

Git is fast. Contrary to SVN, each time you change a file, Git creates new snapshot of this file instead of delta between two files and adjusts the commit tree accordingly. This can take up a bit more space, but makes branching incredibly fast. Since files are marked with their hashes, they are never stored twice, comparisons are very fast and it’s hard to lose consistency either by accident or on purpose. Git is not stupid too in regard of taking up disk space and bandwidth and has sophisticated data storage optimizations.

I remember the pain of switching branches in a project with 30 000 classes versioned under SVN. It’s not the case anymore.

The Host

github-markAs you probably already figured out, you don’t need to use any external host or server to unleash the power of Git. You can download it, create your repo and start committing, branching, checking history, comparing and doing all that neat stuff. At some point however, you might want to share your creations  with the world or just make sure that your repository won’t be gone if your hard drive accidentally dies.

By far, the most popular Git hosting service is GitHub. Its free for open source projects but you can pay to keep your secret endeavors hidden from the community. There are a lot of useful features like hooks, pull requests, comments, team management, various visualizations or Gist.

Another option, backed by Atlassian, is BitBucket. It has one advantage over GitHub as it offers free private repositories with limited number of users. If you are old school player, you can use SourceForge which supports Git for quite some time.

Trivia: currently GitHub is more popular than Pornhub (53th vs 60th place according to Alexa).

The Tool

sourcetreenewicon-300x300Since Git has a bit higher entry cost than SVN, in order to learn some basics, you can start with Git bash. When you get some grasp on how things work, and get tired of typing, I would recommend something more visual, like SourceTree from Atlassian.  It’s free, popular, powerful and intuitive. I’ve tried plugins for Eclipse and Intellij (yes! I’ve finally  switched to Intellij after 7 years of using Eclipse), but SourceTree is better. You can also check out the 5 reasons to use SourceTree blog entry.

Also, since I write a lot of Word stuff recently, and keep some of them under version control, I also enjoyed that SourceTree has out of the box diff on docx files. GitHub can’t do that.

Final Thoughts

Git might seem to be difficult and counter intuitive at first, but learning it is worth the effort in the end. It’s now a de facto industry standard and unless you plan to spend the rest of your career doing Cobol on IBM mainframe in some god-forgotten IT department of definitely non-IT company, you will probably have to learn Git anyway.

If you would like to read more, I can recommend two nice books about Git: Git Pocket Guide by Richard E. Silverman and Pro Git by Scott Chacon. Second one is available for free. There is also a good tutorial on Atlassian site and high quality courses on Pluralsight (if you are tired of random YouTube IT tutorial clips in heavily accented English).



Posted by on September 15, 2016 in Technology


Tags: , ,

2 responses to “Git Intro

Leave a Reply

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

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

Facebook photo

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

Connecting to %s

%d bloggers like this: