Good Bye Subversion, Hello Git
January 05, 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
.gitdirectory 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)
Feedback?
If you’ve found errors or have some feedback please . Comments aren’t currently enabled due to spam but I’m sure they’ll return in the future.