"This is too important to miss out on. This is possibly the biggest advance in software development technology in the ten years I've been writing articles here." - Joel Spolsky

Every so often a software developer comes across a new tool that positively changes the fundamental way they work. This experience is invigorating and refreshing. For myself this seems to happen about once every two or three years it seems if I'm lucky.

Just recently this has thankfully happened in the form of ?Git. There are loads of great articles on Git - why to use it, tutorials, etc.  So instead of repeating those I'll just link to a small subset of the very best ones I would tell 'pre-Git-Brendan' to get started with.

My favorite Git articles and sites:

Why I love Git

It's soooo easy to create your repository:  git init

As an independent contractor type I'm often working with multiple clients on multiple projects. The problem for me is that I'll sometimes work for a few weeks on a particular project but then switch off it for weeks, months or even years but then need to jump back in. For some of these projects I have Subversion repository created, but honestly it's can be a pain to get one started - find an appropriate server, check in your code trying to tip toe around compiled things your shouldn't be checking in, checkout another copy, switch your new 'subversioned copy' around, etc. The worst part is though even when you go to this trouble you often find that if you leave the project and come back some months later the repository has changed locations or your credentials were removed or EVEN history was lost. This seems like it should be rare but happens all-the-time even with the best intentioned of hosts.

Not to complain about Subversion too much because until recently it was the best option. I only mention it because it's important to understand what makes git so easy.

With Git you switch to your project dir, type 'git init' - your repository is created! A couple more commands to check everything in.  $ git init
$ git add .$ git commit -m 'initial commit'It just doesn't get any easier. And since I will have everything (commits, history, etc.) local I know that no amount of other people screwing around upstream will ever cause me to lose this work.

It's super fast

Everything you do is nearly instantaneous. You can just take my word for it or do some more reading. 

It's distributed so no cloud required!

The lack of a server being available or even an Internet connection will never again prevent you from researching your code bases history or making meaningful detailed commits.

Git is extremely flexible

You can literally do just about anything imaginable with Git in terms of version control. Detailing the exotic options before you is beyond my scope or really understanding here. I just stick to my own workflows for the most part. But one quick example is that if you accidentally push or check in a plain text password file for instance (something you clearly don't want to do) you can actually erase that from the history. Powerful - yes. Dangerous - possibly, but really it's like any other tool - to be used for good or evil. And Git does try to prevent you from doing things that you probably don't want to usually be doing.

By the way trying to 'uncommit' a file with secret stuff in Subversion is a bit of a nightmare. Someone who has had to do this in Subversion might use Git for this reason alone.

Git and DVCS in general has huge momentum

DVCS is what's happening in 2010. For a lot of people it was happening earlier certainly. I'm perhaps a little late to this party even. But I think it's safe to say any developer who makes an effort to upgrade their skill sets has picked up DVCS or will be doing so very soon.

The most compelling article I've read on the momentum side is Distributed Version Control is here to stay, baby by Joel Spolsky. His article discusses the other DVCS option Mercurial but everything he says is true of both.

Why I seriously love Git

Committing with reckless abandon!

Since I usually have to do so much context switching I like to commit a lot. With Git this is so fast and easy without screwing anyone else up that I find myself doing it more....A LOT MORE.  In fact I'm starting to use the comment in Git as a way to report in detail everything I've done so I can find my way back later. With Subversion and other systems you just don't commit nearly as often and by the time you do it's pretty easy to forget a lot of the details about what you've done.

One spin on this is just how easy tagging is....as easy as it could possibly be. With Subversion tagging is actually pretty heavy weight, slow and eats up a lot of disk space. I've never been clear on why people take that approach in Subversion but there it is.

I've already gotten loads of mileage out of doing this, not to mention it just feels good. With a DVCS you can optionally wrap up each minor feature or fix with a commit. You needn't worry about the ramifications that commit will have on the larger team. 

If you prefer to pair down the comments in your public commits this is an option - so you don't have to be concerned about the local log you're creating.

Sill have to publish your changes to Subversion or Perforce? No problem!

Git has excellent Subversion integration so it's easy to use Subversion as your public repository. Just as good is that when you clone a Subversion repository to Git you get all the history local! Additionally Git has integration with some other version control systems such as Perforce.

Suddenly all my projects are under version control

No project no matter how small ever needs to be without version control. There are projects I've been coming back to for 10 years where I haven't always adequately documented my most recent changes and the re-discovery process is needlessly time consuming. Git puts an end to this.

SmartGit

SmartGit is a solid, easy to us GUI which has gone a long way towards making Git accessible to me. You still need to really understand Git to use it effectively. I started out trying to use SmartGit as a crutch which was a FAIL. But once I spent enough time learning Git concepts I found SmartGit a great way to get a quick handle on a lot of basic operations. SmartGit seems to currently target and handle the commands I use 90% of the time,  but I find myself definitely needing to revert to the command line in several instances. This is actually with me because I'd still prefer to ultimately have a solid grasp of the command line too.

SmartGit is probably also a faster way to help educated teams of developers on the basic concepts.   But again without understanding the Git specific concepts like the "index" I guarantee you'll quickly get lost.

So give Git a try. Once you've gotten the hang of it you'll feel like you're finally in control of your version control system and not the other way around.
  • No labels