git - 不对 .m matlab 文件进行 git CRLF 转换?

标签 git matlab core.autocrlf

即使在 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/

相关文章:

git - 从所有以前的提交中删除一个目录

matlab - 如何在 MATLAB 中读取 2 channel 音频文件

matlab - 将命令发送到现有的 MATLAB IDE 命令窗口

windows - 在 Windows 中覆盖 .gitattributes text=auto

git - 确保文件在更新 Hook 中将 CRLF 转换为 LF - 是否会影响性能?

git - 致命 : Not possible to fast-forward, 中止

git - 如果不是最新的,则防止 git push 发送整个 repo

git-commit 类似 vim 的语法在 emacs 中突出显示

matlab - 将 MATLAB 图导出为 .eps 时出现字体问题

git - 通过 .gitattributes 强制执行 core.autocrlf=input