【问题标题】:Making `git status` ignore whitespace changes使 `git status` 忽略空白更改
【发布时间】:2014-09-03 14:37:53
【问题描述】:

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 也不起作用。

【问题讨论】:

    标签: git whitespace removing-whitespace git-status


    【解决方案1】:

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

    使用,git checkout -- .

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

    注意:

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

    【讨论】:

    • 这不能回答问题
    • @MohammedRafeeq 让我知道“我怎样才能将这些文件回滚到原始状态(这样它们就不会再被“修改”了)”上面提出的问题没有得到回答。
    【解决方案2】:

    晚了 5 年,但是......

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-08
      • 1970-01-01
      • 2016-01-14
      相关资源
      最近更新 更多