I love you, INDEX

Okay, there wasn’t a blog entry on git for quite a while, but well, here it is. This time about the incredible INDEX mechanism and git add -i. I know that I annoy a lot of people out there with my beloved GIT and I just gave up with trying to explain why GIT is just great. I’m one of those alpha geeks, and I have to realize that a lot of people out there a just too dumb to even understand subversion, so don’t expect them to get into GIT at all. But nevermind, those guys who call themself programmers and don’t like to play around and test new tools, they are…<quote>stupid and ugly<quote> (maybe that’s a web 7.x thingy).

Now a few days ago I discovered git add -i. It’s incredible. Thanks to the staging mechanism of GIT, that acutally don’t add files straight ahead, but moreover ‘stage’ them into an index that is compared and commited to the actual repository. It’s only important what is in the INDEX when you commit and it doesn’t count what is in your working directory. (If you don’t understand this, go ahead and READ, if you don’t do it, you are….stu….you know). So know here is the uber-killer-feature.

You can interactivly browse your patches for certain files, hunk per hunk and just commit a hunk, and not the entire file. So you changed a file and you get annoyed by a bug in another method in the same file. You don’t want do complicated things with stashing, branching, etc so you just edit the method, do a git add -i select the hunk that contains your changes to the method, stage it, and commit it. The other changes are completly untouched.

And by the way: don’t just talk about fancy new agile methods in your elite-buzzword-speech, adopt the right tools for such methods and don’t f**** around with tools that helps you to get people insane when you break dependencies during refactoring while other people need to do a pretty fast hotfix in a bigger environment, well or that ‘when do we merge, please don’t commit while merging, sorry I need to merge that, stop working on that’ thing. It’s getting bored


Posted May 31st, 2008 in Version Control. Tagged: , .

One comment:

  1. Derek Mahar:

    In one of its screencasts (see http://www.gitcasts.com/posts/interactive-adding), GitCasts shows how to use ‘git add –interactive’. The screencast makes this little known, but feature packed command come alive!

Leave a response: