我有一个只能在 Windows 上使用的存储库。而且我希望源代码管理不会以任何方式修改我的文件的内容。
我core.autocrlf在全局设置中设置为 false 并验证不存在本地回购覆盖。我发现我的 repo 中有一个现有的 .gitattributes 文件,* text=auto它是唯一的条目。所以我删除了 .gitattributes 文件。通过阅读文档,我的理解是这应该导致text未指定,并将遵循为core.autocrlf.
但是,当我暂存我的文件时,我仍然收到以下错误:
LF will be replaced by CRLF in MyProject/src/static/images/logo.svg.
The file will have its original line endings in your working directory.
Run Code Online (Sandbox Code Playgroud)
如果我理解正确,有些东西仍然会修改我的文件。它是什么,我该如何阻止它?
首先,正如我在“ Windows git \xe2\x80\x9cwarning:LF将被CRLF\xe2\x80\x9d替换,警告尾部向后吗? ”中提到的,请确保:
\ngit config --global core.autocrlf false(您已经这样做了,正如您的问题中所指定的:好).gitattributes文件,因此svg文件没有文本属性:\n\n\n如果
\ntext未指定该属性,Git 将使用core.autocrlf配置变量来确定是否应转换文件。
其次,检查是否add --renormalize有帮助
git add --renormalize .\ngit commit -m "Introduce end-of-line final normalization if needed"\ngit push\nRun Code Online (Sandbox Code Playgroud)\n然后检查存储库的新克隆是否仍会显示相同的消息。
\n注意:警告消息已随 Git 2.37 (Q3 2022) 更改。
\n| 归档时间: |
|
| 查看次数: |
606 次 |
| 最近记录: |