我们有时会使用SourceTree作为客户端。 它可以处理各种行结尾,但它使用的diff工具却没有。 它将所有以LF结尾的行视为一行。
因此,我们使用CRLF将所有源保存在我们的存储库中。
我正在考虑安装一个git客户端。 我找不到TEXT或AUTOCRLF的正确设置。 看来他们都想在办理登机手续时将文件“规范化”。
我想 结账时转换为CRLF; 或者 登记时转换为CRLF; 要么 签到时什么都不做;
到目前为止我能找到的最好的是 - 文字:在登记或结账时不做任何事情;
有希望吗?
谢谢, 布拉德。
答案 0 :(得分:1)
Git的本机行尾设置是LF,除了从源代码重新编译之外,我不知道有什么方法可以改变这种行为。但是,您可以强制签出以使用CRLF,这需要创建.gitattributes
文件。例如:
# Force C# source files to be checked out using CRLF line endings,
# ignoring "core.eol" setting.
*.cs eol=crlf
# Don't apply CRLF conversion to PDF files, regardless of
# user settings including "core.autocrlf".
*.pdf -text
# All other files are subjected to the usual algorithm to determine
# whether a file is a binary file or a text file, respecting
# "core.eol" for all files detected as text files.
# "core.autocrlf", if set, will force the conversion to/from CRLF
# automatically as necessary for text files.
* text=auto
请注意,如果您创建了一个包含LF行结尾的新文件(例如,使用Linux,Cygwin或默认为LF行结尾的Notepad ++等应用程序),则在将该文件添加到存储库时会收到警告匹配.gitattributes
文件中使用eol=crlf
的模式:
warning: LF will be replaced by CRLF in Example.cs.
The file will have its original line endings in your working directory.
当然,如果您稍后进行新的更改,原始的LF行结尾将不再存在。
以下是各种EOL /文本设置之间的交互列表:
.gitattributes
档案
eol=...
lf
和crlf
。core.eol
和core.autocrlf
。text
core.eol
和core.autocrlf
。text=auto
core.eol
和core.autocrlf
的文字文件。core.eol
和core.autocrlf
二进制文件。-text
core.eol
和core.autocrlf
,因为它们不适用于二进制文件。core.autocrlf
配置设置
input
:签入的任何文本文件都将从CRLF转换为原生LF。true
:签入/签出的任何文本文件都会进行CRLF转换。eol=...
中某些文件的.gitattributes
规则覆盖。core.eol
配置设置
native
(默认):签出的任何文本文件都有本机行结尾(Windows上的CRLF,其他地方的LF)lf
:签出的任何文本文件都有LF行结尾crlf
:签出的任何文本文件都有CRLF行结尾core.autocrlf
设置为true
,则忽略此设置。eol=...
中某些文件的.gitattributes
规则覆盖。