gpt4 book ai didi

c# - Git: 当我想要 LF 时,LF 被 CLRF 取代了?

转载 作者:太空狗 更新时间:2023-10-29 14:42:36 24 4
gpt4 key购买 nike

我正在 Windows 10 上开发一个 Unity 3D C# 项目,并开始一个新的存储库,我将其添加到我的 .gitattributes 中。文件:

# These files are text and should be normalized (convert crlf => lf)
* text=auto
*.cs text diff=csharp

我预计当我添加和提交文件时,git 会在对象数据库中将 CRLF 转换为 LF(如 here 所述)。相反,我收到类似
warning: LF will be replaced by CRLF in <file path/name>
的消息这表明相反。 LF 将替换为 CRLF。

我想要的功能是我的本地 Windows 系统能够混合 LF/CRLF,但是提交时应该将文本文件中的 CRLF 转换为 LF。

为什么我得到了错误的功能?

最佳答案

我刚刚在工作中遇到了这个问题。在你的 .gitattributes 添加:

* text=auto eol=lf

这是因为 Windows 和 Unix 的行尾不同。 LF是Linux下的,上面是强制保存到LF的命令。

关于c# - Git: 当我想要 LF 时,LF 被 CLRF 取代了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49244315/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com