Ignore Git's Suspicious Patch Lines

Those who follow me on Twitter have recently been forced to endure a steady stream of rants directed at Git, the DCVS I’ve been trying out while working on the new theme for this site (one really is coming). I’ve only tweeted a fraction of my frustration, but this tweet sums it up nicely:

What the fuck is up with git and its need for precisely zero trailing whitespace?! Suspicious patch lines my ass.

It seems that Git is a finicky little bastard and it pays obscenely close attention to whitespace. If there is a line, any line, with whitespace at the end of it Git decides that something must be fishy. I mean, it’s whitespace. Horror. Everyone knows whitespace is the very spawn of Satan, right? Er, no. Nonetheless, if there’s any trailing whitespace to be found in content that’s being committed, Git balks:

*
* You have some suspicious patch lines:
*

The message then proceeds to itemize its suspicions for my viewing pleasure. Tonight I’d finally had enough. I can’t figure out how to make Git force the commit or at least stop it from worrying its pretty little head over a little empty space, so I took drastic measures:

$ sudo chmod a-x /path/to/my/repository/.git/hooks/pre-commit

That’ll teach it to mess with me.

Subscribe3 Comments on Ignore Git's Suspicious Patch Lines

  1. Jakub Narebski said...

    You can force a commit using “git commit —no-verify” (it bypasses commit hooks).

  2. Daniel White said...

    New repositories (as of ~1.6.0) install the hooks with a .sample extension so they don’t run by default.

  3. Alpheus said...

    Well said! I’m new to Git, and I’m liking it so far…but this is such a bizarre thing to get caught up on! It’s my understanding that the latest versions of git don’t have this problem. (I’m using Debian Lenny, so apparently my version isn’t the latest!)

    It’s an interesting idea, though: to have a script that checks for something before you commit. But why did it have to be whitespace?!?

Leave your own comment or...subscribe to those of others

Formatting may be applied to comments using Textile markup.