What is the easiest way to convert all files in git repo to LF line endings

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 14:23:53

问题


So I have an old repo, with many files, some are CRLF, some are LF.

I want to

(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) prohibit all future checkins that have CRLF or auto-convert them to LF.

How do I do so?

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.


回答1:


Try to set following in your .gitattributes and refresh your repository:

* text eol=lf


来源:https://stackoverflow.com/questions/27625299/what-is-the-easiest-way-to-convert-all-files-in-git-repo-to-lf-line-endings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!