请你解释一下git中的空白错误,它们是什么意思,什么是“压抑”,我需要担心它吗?
(运行msysgit,但在linux上与其他用户一起运行)。
对于autocrlf here (将其设置为false git config --global core.autocrlf false
)
答案 0 :(得分:25)
Squelching最初是一种用于电信的功能,用于设置一个阈值,高于该阈值时,信号通过或不通过。
在您的情况下,当您看到:
warning: squelched 104 whitespace errors
warning: 109 lines add whitespace errors.
这意味着:它不是显示100多个错误消息,而是警告您它应该显示这些错误(但不会,为了不使输出混乱)
我对空白政策没有明确的建议,除了从一开始就确定它们的原因 如果您的编辑器没有在Window和Unix之间转换eol(行尾)字符,那么它意味着它以某种方式自动添加或删除空格,这并不总是有用。
第一个测试(如此blog post)是取消激活策略:
git config core.whitespace nowarn
或尝试
git config core.whitespace fix
并查看是否有助于您的rebase操作。
答案 1 :(得分:16)
以下是使用git apply时修复“尾随空格”错误的方法:
您需要知道的第一件事是:什么是空白错误。这在core.whitespace setting documentation上有解释。基本上,git处理几种空格错误:
blank-at-eol
blank-at-eof
space-before-tab
indent-with-non-tab
tab-in-indent
cr-at-eol
使用Windows样式行结尾(CRLF)修补文件时, 尾随空格错误可能会上升。
要避免此警告,您可以要求git apply
不显示警告:
git apply --whitespace=nowarn fix.patch
或者你可以动态编辑git配置 <(-c
)来说“ok git,这次CR在行尾很好”:
git -c core.whitespace=cr-at-eol apply fix.patch
如果您想要永久,只需编辑git配置:
git config apply.whitespace nowarn
或:
git config core.whitespace cr-at-eol
答案 2 :(得分:13)
在搜索完该答案并查看git-config和git-apply手册后,我发现
git config apply.whitespace nowarn
停用显示当前存储库中的空白错误。
要使其可用于所有存储库,只需添加--global
,如下所示:
git config --global apply.whitespace nowarn