It seems every man and his dog is using Git for version control these days and I’d been feeling a tad left out of late. You see I’ve been using Subversion for close to seven years now both for personal projects and at WeeWorld (we used SourceSafe in the very early days but that’s best forgotten). And previous to all that I used CVS in various other jobs. For some reason however, Git always seemed like a mysterious dark force that was best left alone.

Well I finally decided to actually spend a few days getting to grips with Git and I must say it’s actually pretty straightforward. Git’s branching model is really nice and I love the fact that I can very quickly create and work with new branches, and just as easily switch between branches. Being distributed, most operations are performed locally, making it much faster to work with than the likes of SVN, which always requires communication with a server. In fact, there were quite a few times recently when I had no internet connection but was still able to happily work away.

I’m certainly no Git expert but hopefully I’ve got my head around the basics and I’ll continue to use it for personal projects. I got myself setup with a Bitbucket account which lets me create unlimited private repositories with up to 5 users. I’ve actually mostly been using the command line at the moment but I also have the SourceTree client. Oh and I bought and flicked through the pages of Git – Version Control for Everyone, which I thought was a very good introduction.

  1. It’ll change how you code and all other free VCS will seem stupid (except mercurial) 🙂

    You don’t need to buy a book to get started – one of the best books is “Pro Git” which, while available in print, is also online in full at . You can grab PDF, mobi and ePub versions from there too.

    I highly recommend using git from a command line as much as possible. It has an excellent and generally fairly helpful command line interface, and you’ll get a far greater understanding for what it’s doing, ultimately. Most of the GUIs don’t support (or support in a very clunky fashion) the lesser known, but incredibly useful git commands such as the stash ( ) and reflog ( ). Reflog in particular can be invaluable when you think you may have accidentally nuked some work with git 🙂

    Github maintains an excellent repository of .gitignore entries for all sorts of apps and OS’s for what files you should ignore in commits at and there’s also a nice command line utility for grabbing them called gibo:

    Finally, if you’re on a mac you can have a look at this article I wrote to add some useful things to your command prompt so you know at a glance where you are in a git branch: (a little out of date, but a reasonable start). If you’re using Windows, take a look at posh-git instead for similar information:

    Finally finally, I recommend using github as well as bitbucket. Github has (IMO) far superior tools for collaboration and for open source project sharing, and it has the excellent code pasting service. Bitbucket is a good cheap way to maintain private repositories though. I tend to do all my open source stuff on github and keep my inactive private stuff in bitbucket (I have a paid github account so I can keep a few active private repos there). Because of the distributed nature of git, it’s trivial to push updates to both github and bitbucket from a single repository, or migrate from one to the other keeping all history intact.

  2. Whoops. That was a bit of a long comment. I really should have made that a blog post 🙂 Sorry.

  3. Thanks for the info Dave!

    Christopher (Author)