我是 git 的新手,我已经阅读了很多关于行尾和
git 如何对待它们。顺便说一句,我在 Windows 上。我做了
一个 .gitattributes
文件并将例如 *.txt 设置为文本。
当我提交 .txt 文件时,我收到警告:
warning: CRLF will be replaced by LF in whatever.txt
但我知道。我不需要那个警告。更换线 文本文件中的结尾是我想要的。
现在,将 safecrlf
设置为 false 会发出警告
消失了,但是 safecrlf
的手册是这样写的:
If true, makes git check if converting CRLF is reversible when end-of-line conversion is active. Git will verify if a command modifies a file in the work tree either directly or indirectly. For example, committing a file followed by checking out the same file should yield the original file in the work tree. If this is not the case for the current setting of core.autocrlf, git will reject the file.
由此看来,safecrlf
似乎是个好主意。
但是,我不明白为什么要将 safecrlf
设置为 true
给我关于我的文本文件的警告;在我看来,这
这些是不同的问题——文本文件的警告和
检查是否可逆。事实上,git 不会拒绝我的
文件。
我能否去掉文本文件的警告,并且仍然有
safecrlf
设置?还是我误解了什么?
最佳答案
据我所知,将 core.safecrlf
设置为 false
是关闭该警告的唯一方法。
safecrlf
如果您的属性设置正确,通常不需要。 safecrlf
的 Gist 是防止在存储库中应该具有混合(或非 LF)行结尾的文件中进行规范化。它实际上只与 core.autocrlf
结合使用(以确保其自动猜测不会破坏任何东西),并且如果您通过 .gitattributes
设置自己的属性> 关闭所有这些应该没问题。
关于git:如何在不禁用 safecrlf 的情况下摆脱 "warning: CRLF will be replaced by LF"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16873848/