即使在 Windows 上,Matlab .m 文件也使用 Unix LF 行结尾。我希望设置 git 配置文件,以便 .m 文件不会像其他常规文本文件那样转换回 CRLF(即我在 repo 协议(protocol)中使用 LF 作为默认样式,即使它是 Windows)。
这可以做到吗?
编辑:来自 Matlab 2008b 手册。 (在编辑和调试 M 文件下)
Line Endings Removed in Files Provided with MATLAB Software for Windows Platforms; Impacts Viewing in Notepad Application
In previous versions, text files provided with MATLAB for Windows platforms included a carriage return and line feed at the end of each line. Starting in R2007b, the text files MATLAB provides do not include a carriage return and line feed at the end of each line.
File types affected are: .asc .bat .c .cc .cdr .cpp .def .for gs.rights .h .ini .m .mdl .pl readme .tlc .tmf .txt
There is no impact if you view the files in MATLAB and other common text editors, with the known exception of the Microsoft Notepad application.
Compatibility Considerations. If you use the Notepad application to view files provided with MATLAB, you see carriage return and line feed symbols instead of line endings. This makes the files less readable in the Notepad application. Other text editors might display the symbols instead of line endings, but of the common text editors tested, none have been found that do so.
As an alternative to the Notepad application, use the Microsoft WordPad application, provided with Windows platforms, or another text editor to view the files.
最佳答案
在 Windows 上将 core.autocrlf
配置设置为 false,将 core.eol
配置为 lf
。
[core]
autocrlf = false
eol = lf
另外,看看 gitattributes
在 checkout 和 checkin
关于git - 不对 .m matlab 文件进行 git CRLF 转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6823168/