我想设置 git,以便将所有 LF 结尾更改为 CRLF。
我在我的存储库的根文件夹中创建了一个 .gitattributes 文件:
* text=auto
# Have git change every .groovy and .java file to crlf
*.java eol=crlf
*.groovy eol=crlf
当提交一个我知道有 LF 结尾的 .java 文件时,我希望在 checkout 到新的本地分支时它会更改为 CRLF。但事实并非如此。有什么想法吗?
最佳答案
我相信您需要在“eol”属性之前指定“text”;所以你的例子将变成以下内容:
* text=auto
# Have git change every .groovy and .java file to crlf
*.java text eol=crlf
*.groovy text eol=crlf
关于创建 .gitattributes 文件后,Git 不会更改行结尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26401431/