CreativeFlux

Good Bye Subversion, Hello Git

January 5th, 2008

Recently, I had a bit of a disaster with Subversion. Unbeknown to me over the Christmas period my repository somehow “broke”, I was unable to retrieve any of my previous revisions and as a result all I was left with was some high experimental code I’d been working on in a branch on my local system. So basically I had lost pretty much everything.

I know what you’re thinking already, I should have had it backed up, I did, but unfortunately not knowing the time it went bad made restoration impossible (since I only have so many backups of my slice).

That’s how I came to try out Git and boy am I glad I did…

Git is an SCM just like Subversion is, only Git is distributed which in this instance is very important. When you check out from Subversion, you’re pulling the latest version of the code from the repository and when you check back in all of your changes go straight back up to the server. That remote server is a single point of failure. If it goes down, you can’t check in or check out any code at all, not good.

By comparison, the distributed nature of Git means that, when you checkout from the repository, you actually get a copy of the entire repository on your local system. So right off the bat you’re essentially getting free backups since everyone who’s checked out has a copy of the repository. All you would need to do to get back up and running is copy your local repository up to the server and you’re good to go. Furthermore, because you have a local copy, you can commit, branch, revert and do all of the things you usually do without being on the internet. All of the changes you make get put into your local copy of the repository and then you simply “push” your changes back out to the remote server. You can also define multiple remote locations so you can push to several locations very easily, adding even more redundancy. (Not that that’s an excuse to forget about backing up the main machine!!!!)

The above, for me personally, is the killer feature Git has over Subversion, but there are other benefits too:

  • It’s cleaner, just one .git directory that takes up very little space
  • Branching is ridiculously fast and easy
  • Speed
  • It works with Subversion repositories too!
  • It seems easier (take this with a pinch of salt as it’s a personal observation)

Get Git

If you’ve suddenly been inspired to give Git a go then you can head over to the Git website and grab a copy there. You can also install using mac ports, apt-get or whatever package management you use, the package is normally called git-core.

Personally I think it’s better to build from source, it was easy enough to do on my mac (make sure you have the developer tools installed), there were some dependency issues with the man documentation so I skipped that since I can read it online anyway:


  wget http://kernel.org/pub/software/scm/git/git-1.5.3.7.tar.gz
  tar xvzf git-1.5.3.7.tar.gz
  cd git-1.5.3.7.tar.gz
  make all
  sudo make install

5 lines, pretty simple huh!?

Just as a final note (since I’ve seen a lot of discussion in many forums regarding git and svn) I’m not saying that Git is the best for everyone. It’s not. SCM is a personal thing, it’s about what fits into your development workflow. I love the whole distributed set-up so Git is a great fit for me but if you prefer keeping everything in one place (it does have its perks such as easier tracking) then you’ll probably go with Subversion.

My next entry may cover my Git set-up on my ubuntu slice (comments/emails pending). Oh and since this is my first entry of 2008, Happy New Year! (admittedly somewhat belated)

6 Comments commentsrss

Stefan

5th January 2008

Yes, Git is the best solution I stumbled upon last year. I do since summer nearly everythink in Git. And the best is, with git-svn its even possible to keep the Git-Repository in sync with an Subversion-Repository.

Michael Trier pointed me to a cheap Git screencast ($9), which is very good.

Stefan

5th January 2008

Well, I assume you don't use Markdown for comments, right? Would be nice to know, what kind of Markdown to use…

Dru Owner

5th January 2008

Yes, sorry about that, it seems my formatting isn't working properly. I'll tidy up your comment shortly. And yes, that screencast is excellent!!

River

6th January 2008

I was looking at SCM for a while, and I’ve heard nothing but bad things about Subversion so far. I’ve read plenty of things about git, but it’s just way too complicated with all the terminology and the branches and tags and all that.

The screencast that @Stafan mentioned though looks awesome. I really want to start using a SCM, since my system of constantly losing/moving/deleting/overwriting files is starting to get really frustrating. :P

Dru Owner

7th January 2008

I know exactly what you mean, all the lingo baffled me initially. So when I first got started, in my case with subversion, I completely ignored branching and whilst I did start doing it later, I benefited from using SCM right away. So I would say you could still get a lot from it just by doing the basics.

Arnold

15th January 2008

Haben sie ein zimmer noch frei?

Post a comment

Comments are closed for this entry.