使 `git status` 忽略空白更改

Gre*_*zak 5 git whitespace git-status removing-whitespace

git status告诉我,很少有文件被修改。但是当我使用git diff下面的任何参数执行时,它都是空的。

   --ignore-space-at-eol
       Ignore changes in whitespace at EOL.

   -b, --ignore-space-change
       Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.

   -w, --ignore-all-space
       Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.
Run Code Online (Sandbox Code Playgroud)

我尝试git checkout .重置此更改,但没有帮助。我怎样才能将此文件回滚到原始状态(这样它们就不会再被“修改”)或git status永久忽略空白更改?

git reset --hard也不工作。

Vin*_*uri 2

如果你想放弃当前 git repo 中的所有更改

使用,git checkout -- .

请检查需要清理的文件是否有用于git clean -n未跟踪的文件。

笔记:

请务必小心git reset --hard,这会删除所有未提交的文件。更改将永久丢失(无法恢复)。