What’s so great about git?

Over the last few days, I have been asked several times why I like git. Many explanations and detailed comparisons exist that discuss how git compares to other version control systems. I’m not going to try and duplicate any of that work. These are just some thoughts about features in git that allow me to work more productively.

I didn’t immediately grok git because it is fundamentally different from subversion. Subversion tracks the history of files whereas Git tracks the history of content. That difference may seem minor, but the shift brings a lot of flexibility. You can expect a small learning curve, but don’t give up! If git works as well for you as it does for me, you will not want to go back to subversion.

So, what are my favorite things about git?

  • Branching: Coming from a CVS/SVN background, I didn’t think git’s “cheap branching” would matter to me. I am not exaggerating when I say that it has dramatically changed the way I work. Because branching and merging are so easy, I create a new branch for each feature or bug I’m working on. I am never tempted to check in broken code just because I want a checkpoint.
  • The index: It is really nice to be able to just check in a portion of the changes in my code rather than having to commit the entire file.
  • git stash: If I’m in the middle of some big change and need to fix a small bug, I can hide my outstanding changes, make the fix and restore my changes without a checkin.
  • git rebase: Sometimes it is really handy to be able to rewrite history.
  • Git is a DVCS: My work isn’t crippled when I am not connected to the network. I can check code in and out. I can branch and merge. I have a full history of the repository. Awesome!
  • Very flexible workflow: With git I can push/pull to a central server like CVS or SVN. Alternatively, changes can bypass the server and be sent directly between working repositories.
  • Git is fast: Neither CVS nor SVN come close to git’s speed.

Is git perfect? No. Off the top of my head, here are some things that I would really like to have in git:

  • git checkout -i: Sometimes I want to rollback a few changes in a file. I imagine this would work very similarly to ‘git add -i’.
  • git stash -i: Sometimes I only want to stash some of my changes. This too would work like ‘git add -i’.
  • Local tags: Local branches are great; local tagging would be too.
  • Track empty directories: I understand why this doesn’t currently happen, but it can be obnoxious.
  • Comments on branches: It is easy to make a lot of branches but unless your branch names are super descriptive (and therefore super long), it is also easy to forget what each of them is for.
  • Better/more documentation: In general I am able to find what I’m looking for, but I still don’t know what the “fetch-all” in git svn fetch --fetch-all actually does.
  • Windows support: Not that I’ve actually tried it, I’ve just heard that it doesn’t work well.
  • GUI options: Most of the time I work in the cli but sometimes a gui is more convienent. I’ve heard multiple people ask for a tool that would allow them to branch and tag without checking out code. gitk and gitx just don’t offer all the flexibility that some other tools do (e.g. WinCVS, SmartSVN, TortoiseSVN, etc.).

Why do you like (or hate) git?