git强制文件行结束于提交 [英] git force file line ending on commit

查看:128
本文介绍了git强制文件行结束于提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有多平台项目,为少数平台生成二进制文件,例如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 are lf, crlf and native, 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆