Why I Love Git (or Git vs. Subversion) July 26, 2010 at 11:55 pm

I have used Git before but only in small trials. Due to the ancient servers I was previously interacting with, I was unable to upgrade from SVN to Git. However, some recent changes have finally allowed for this.

I will never go back.

First off, I must say that there is not one thing I could do in SVN that I can’t do in Git. And to be fair, there are very few things that Git can do that SVN can not. Every branch, commit, tag and other feature in SVN seems to be available in Git and vice versa. But Git provides some secret sauce on top that has changed my life forever.

Branching as a Way of Life

Branches, tags and managing those particular intricacies of release management used to be cumbersome. Everyone had their own way of doing it. Helper scripts were available for SVN (like svnmerge) that would track your commits and work and help make friendly merges across branches. But they all were a bit cryptic and hackish – usually requiring separate downloading of some script and some secret command lines and such. Generally, it was a pain. And it was slow and, sometimes, insecure.

Git makes branching incredibly simple. INCREDIBLY simple.

If you want to create a branch, you make sure you are checked out in whatever you are branching, and then you just type:

git checkout -b new-branch-name

All done. To keep life organized, you can make up your own fun branch name with versions. We use modulename/1.x to designate a module/feature and a version. Easy.

Switching branches is just as easy. Same command as above, but without the -b. Sweet. Git will automatically switch to the other branch, assuming you haven’t changed any files in the current branch. If you have, it will politely list which files and ask you to fix the problem – with lots of verbose instructions. Yum.

But here’s what’s really nuts… Because this is so easy, I actually find myself using git’s branch feature more regularly. Like, every 30 minutes or so. Working on open-source projects makes you a bit ADD – people are chatting all day with suggestions, features, bugs and some are quick to implement, but you have to be able to hop around – quickly. I would never dream of tracking things like I am using SVN. It would take hours.

Committing Locally

Committing locally has changed my life as well. We used to commit a lot of broken code to the repository. We’d do this because, mid-stream down an idea, we sometimes thought “gee, we should do this differently.” But in case the “differently” way didn’t work, we wanted a way to “go back”. Or sometimes we’d want to share what we’d done so far with a teammate. This was hard to do when it was constantly coupled with merging and branching. We could be doing this 20 times a day, being that our contributors and programmers are spread across the US. Nobody can “run over to my screen” to look through things. And since we use IDEs to program in, screen sharing wasn’t an option.

Git’s ability to allow you to commit locally or off a private shared repo before pushing to a public repository has, again, been so unbelievably easy, you sort-of have to be brain dead not to get it. And it’s, again, changed our workflow. We regularly commit our work now – tracking each individual change – and we revert more often, which saves us time when we make mistakes. Before we’d just have “code we deleted.” Now it’s all tracked.

Infrastructure Be Gone!

In addition, setting up SVN with more strict access controls and to use Apache with any sort of security required usually required loading mod_subversion and some other funky stuff in Apache. Annoying. Git, however, uses SSH. There are WAY MORE tools for SSH key management and it’s inherently secure without any loaded modules on the server. We’re using gitolite so we can go even further, but even that isn’t required. Stupidly simple AGAIN.

Oh, and all this branching stuff – WAY fast on Git. Local commits and creations of branches is near instant, even on a large project. Only when we’re ready to be “finished” and have to pull or push changesets to the server do we see any delays.

Not All Roses

Subversion is still the defacto in many places – and it shows. Our IDE doesn’t support Git yet. Many features Git has aren’t exposed in our hosting provider’s interface (assembla) such as submodules. And we do find some features (such as submodules) complex.

We’re still learning.

That said, I’ll never look back. Git is an amazing upgrade to an already amazing version control world we live in. Three cheers.

Read More On Git:

Ten Git Tips & Tricks for Beginners

Gitolite (from Pro Git)

Managing Multiple Git Clients

Leave a Reply

You must be logged in to post a comment.