git强制文件行结束于提交 [英] git force file line ending on commit
问题描述
我们有多平台项目,为少数平台生成二进制文件,例如mac,windows,linux ...是否可以强制git将所有文件的编码更改为某个特定平台(例如:Linux)。那么,如何在每次用户提交或推送到远程存储库时更改文件的行结束符?解析方案
我会推荐设置 core.eol
.gitattributes code> file
,而不是依赖像 core.autocrlf
这样的全局配置。
core.eol
套在工作目录中用于文本属性设置的文件的行结束类型。
其他选项包括lf
,crlf
和native
,它使用平台的本地行结束。
默认值是本机。
查看 gitattributes(5)以获取有关最终用户的更多信息。在线转换。
We have multi-platform project, which generates binaries for few platforms say mac, windows, linux... Is it possible to force git to change encoding of all files to some particular platform (For example: Linux). So how to change file's line ending every time when users commit or push to remote repository?
I would recommend setting core.eol
directives in .gitattributes
file, rather than relying on a global config like core.autocrlf
.
core.eol
Sets the line ending type to use in the working directory for files that have the text property set.
Alternatives arelf
,crlf
andnative
, which uses the platform's native line ending.
The default value is native.
See gitattributes(5) for more information on end-of-line conversion.
这篇关于git强制文件行结束于提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!