Git: You have some suspicious patch lines…

Monday, December 29th, 2008 at 7:46 pm

So, I’ve run into this a few times now and it seems like bizarre behaviour to me. While committing, git complains about files which have trailing white space, or spaces followed by a tab. While this may not be the nicest formatting, enforcing this to be fixed before committing a file seems odd.

It turns out this is being caused by a pre-commit hook. There are two options you can go with to circumvent the issue.

git commit --no-verify .

The –no-verify will bypass the pre-commit hooks. This only works on the current commit thought, so you have to add the flag each time you want to commit.

I’ve found that if you

cd .git/hooks/
chmod -x pre-commit

will disable the pre-commit hooks permanently by removing the executable rights on the file.

Apparently they are disabled by default in newer releases.

Hope this helps someone else out as well.

Tags: ,

7 Responses to “Git: You have some suspicious patch lines…”

  1. Alfredo says:

    thanks a lot from Argentina!!!

  2. Alpheus says:

    Apparently this doesn’t work under CygWin. I’ve resorted to re-naming “pre-commit” to “pre-commit.bak”.

    Or maybe it’s just that I’m trying to read a CygWin directory from a VirtualBox Linux instance via shared drive…

  3. Dan says:

    sorry, I don’t have any experience with using git combined with CygWin. Let me know if you find out a good solution though :)

  4. Nishant says:

    GIT + Cygwin. Anyone knows how to turn off the annoying trailing white-space error? (permanently) other than –no-verify

  5. Thanks a lot for the tip. That’s exactly that started to show up after I’ve chmoded my rails app to 0755.

  6. iarenaza says:

    As Alpheus did, renaming the file is the recommended way to turn off hooks on Windows.


  7. Evan says:

    Alternately (on Windows): modify the file. Look at lines 58-60; I think they were. I deleted them.

Leave a Reply