git commit You have some suspicious patch lines

git commit giving me the following message

* You have some suspicious patch lines:
* In projects/bong/traid/apps/controller/project.php
* trailing whitespace (line 220)
* trailing whitespace (line 223)

What does that mean ?

  • What's the easiest way to deal with project configuration files?
  • Using GitHub with another Bug-tracker?
  • What Are Some Actions In Git That Are Difficult/Impossible to Undo?
  • Vim using non-standard configuration when called from `git commit`?
  • git rebase from a url/path
  • Did Apple remove the 'git gui' command in XCode 4.5 command line tools?
  • Reset or revert a specific file to a specific revision using Git?
  • can't push a new repo
  • Allow agent forwarding using Cmder (ConEmu)
  • How to use Git?
  • Verify changes in git modules
  • how to add files/folders to gitignore in intellij GUI?
  • 3 Solutions collect form web for “git commit You have some suspicious patch lines”

    That happens when the file has trailing whitespace, if you run:

    git commit --no-verify

    it will commit ok.

    I find it disturbing to just deactivate pre-commit altogether. If you have a look at the content of .git/hooks/pre-commit, it also checks for unresolved merge conflicts, and I would like to continue to check for those!

    Towards the end of the file it runs some regular expressions that check for spaces at line endings and untidy tab characters. I just commented out these lines so it doesn’t look for those, and I got rid of the pre-commit warning problem.

     55     if (s/^\+//) {
     56         $lineno++;
     57         chomp;
     **58         # if (/\s$/) {
     59         # bad_line("trailing whitespace", $_);
     60         # }
     61         # if (/^\s* \t/) {
     62         # bad_line("indent SP followed by a TAB", $_);
     63         # }**
     64         if (/^([])\1{6} |^={7}$/) {
     65         bad_line("unresolved merge conflict", $_);
     66         }
     67     }

    In short, it means that you have trailing white space on the lines mentioned. Trailing white is a bit of an odd choice, and sometimes is a compiler error or other error waiting to happen.

    You can either clean up those lines, or you can force the commit just this time by adding the –no-verify flag to your git commit.

    Alternatively, you can just turn off this checking by disabling pre-commit hooks, like this:
    cd .git/hooks/
    chmod -x pre-commit

    BTW, this answer is extracted from:

    Git Baby is a git and github fan, let's start git clone.