首页 > 解决方案 > 通过 .gitattributes 文件禁用行尾规范化

问题描述

如何通过 .gitattributes 文件禁用行尾规范化(行终止符)?或者更有用的是,对某些路径和/或文件禁用它。此外,我希望 Git 像往常一样显示文本文件的差异/合并。

由于有时您需要根据操作系统(即* text=auto.gitattributes文件中使用)对文本文件的行尾进行规范化,如何实现排除?

标签: gitnormalizationline-endingseolgitattributes

解决方案


鉴于所有文本文件都在 .gitattributes 文件中进行了规范化,我们可以使用以下!eol选项添加排除项:

# Auto detect text files and perform EOL normalization according to OS
* text=auto 

#Exclude certain file types from EOL normalization
*.csv !eol

#Exclude certain paths from EOL normalization
**/TestFilesPath/** !eol

推荐阅读