使`git status`忽略空格的变化

时间:2014-09-03 14:37:54

标签: git whitespace removing-whitespace git-status

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.

我已尝试git checkout .重置此更改,但它没有帮助。如何将此文件回滚到原始状态(以便不再“修改”)或使git status永久忽略空格更改?

git reset --hard也无效。

2 个答案:

答案 0 :(得分:3)

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

使用,git checkout -- .

如果对未跟踪文件使用git clean -n,请检查需要清理的文件。

注意:

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

答案 1 :(得分:1)

晚5年参加聚会,但是...

在导出Drupal 8配置(drush cex)时,我经常会遇到这种情况。我将立即运行git stash save,然后运行git stash popgit status仅报告具有实际更改的文件。

相关问题