1

i modified a file "index.php", and i want to apply a push for the second time so i apply those commands:

git add /path/to/index.php

git commit --amend

but i have this result :

/path/index.php:7: trailing whitespace.

/path/index.php:52: trailing whitespace.

/path/index.php:62: trailing whitespace.

/path/index.php:81: trailing whitespace.

What i want is to commit ignoring those whitespaces that are existing from the beginning in this file , i don't want to remove them.

Forcing the commit to ignore those whitespaces

I hope that any one have a solution for this issue.Thank you for your Help

Baini.Marouane
  • 579
  • 2
  • 8
  • 18

3 Answers3

4

Use the --no-verify option. Somebody did bother to write the custom code that's refusing things that look like what you're committing, you sure you want to this?

jthill
  • 55,082
  • 5
  • 77
  • 137
0

I don't think you can turn off the warnings/errors with git.

Have a look at this answer for reason.

Why does git care about trailing whitespace in my files?

Why do you not want to remove them? Keeping them around can mess up future patches.

Community
  • 1
  • 1
Phil Poore
  • 2,086
  • 19
  • 30
0

I don't think there's any way to ignore whitespace in git, nor should there be - whitespace is data and git tracks changes to data, not code.

But what you can do, is suppress showing whitespace in your diffs with git diff -w (and with a github diff by adding the url parameter ?w=)

erik258
  • 14,701
  • 2
  • 25
  • 31