将git repo中的所有文件转换为LF行结尾的最简单方法是什么 [英] What is the easiest way to convert all files in git repo to LF line endings
问题描述
所以我有一个老仓库,里面有很多文件,有些是CRLF,有些是LF.
So I have an old repo, with many files, some are CRLF, some are LF.
我想
(1)将所有文件更改为LF(我已经使用dos2unix转换了文件,但是git commit忽略了这些更改!)我还将git config --global core.autocrlf设置为false.
(1) change ALL files to LF (I have used dos2unix to convert my files, but git commit ignores those changes!) I have also set git config --global core.autocrlf to false.
(2)禁止以后所有具有CRLF的签到或将其自动转换为LF.
(2) prohibit all future checkins that have CRLF or auto-convert them to LF.
我该怎么做?
对不起.我在这里阅读了多个帖子,我简直不敢相信这是违反直觉的.我似乎有许多配置,例如core.safecrlf,core.autocrlf,.gitattributes等,但我不敢相信对于人们来说,这个简单的任务是如此复杂,并且错误消息还不清楚.
Sorry for the rant. I have read multiple posts here and I can't believe this is so counterintuitive. I have seem many configs like core.safecrlf, core.autocrlf, .gitattributes etc, but I can't believe this simple task is so complicated for people to master and error messages are so unclear.
推荐答案
尝试在.gitattributes中设置以下内容并刷新存储库:
Try to set following in your .gitattributes and refresh your repository:
* text eol=lf
这篇关于将git repo中的所有文件转换为LF行结尾的最简单方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!