使用 Git,如何关闭“LF 将被 CRLF 替换”选项警告
在 Git 中,当使用 autocrlf = true
标志时,更改行结尾时仍会发出警告。
我了解警告的用途,以及如何关闭行结束标志,但如何关闭警告本身?
With Git, when using the autocrlf = true
flag, a warning is still given when line-endings are changed.
I understand what the warning is for, and how to turn off the line-ending flag, but how do I turn off the warning itself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您正在寻找
core.whitespace
选项(有关详细信息,请参阅git config --help
)。您可以像这样设置此选项:
You're looking for the
core.whitespace
option (seegit config --help
for details).You can set this option like so:
有趣的是,我已经应用了这里解释的两个配置,并且我的 .gitconfig 文件包含以下两行:
但我收到了警告。
现在,为了尝试,我注释掉了这两行,警告实际上消失了。
不知道为什么我把它们放在第一位,但是......
Funnily enough, I had applied both configs like explained here, and my .gitconfig file contained these 2 lines:
Yet I got the warning.
Now just to try I commented out both lines and the warning actually disappeared.
No idea why I put them in the first place however...
设置“core.safecrlf false”有效。但是,在我将值更改为“true”后,输出从“警告”更改为“致命”,如下所示。
Setting "core.safecrlf false" works. However, after I changed the value to 'true' The output changes from 'warning' to 'fatal' as shown below.
您可以使用以下命令关闭警告
(这只会关闭警告,而不会关闭功能本身。)
You can turn off the warning with
(This will only turn off the warning, not the function itself.)
您应该使用
core.autocrlf input
和core.eol input
。或者只是不要让 git 使用autocrlf false
根本改变行结尾,并使用core.whitespace cr-at-eol
消除差异中 crlfs 的突出显示等。希望这有帮助
You should use
core.autocrlf input
andcore.eol input
. Or just don't let git change the line endings at all withautocrlf false
and get rid of highlighting of crlfs in diffs, etc withcore.whitespace cr-at-eol
.Hope this helps
我用的是这样的方式:
https://help.github.com/articles/dealing-with-line-结局/
I used this way:
https://help.github.com/articles/dealing-with-line-endings/