- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我在 Stack Overflow 以及 git 文档中阅读了很多关于 core.autocrlf 设置如何工作的不同问题和答案。
这是我读到的内容的理解:
Unix 和 Mac OSX(OSX 之前使用 CR)客户端使用 LF 行尾。
Windows 客户端使用 CRLF 行结尾。
当客户端上的 core.autocrlf 设置为 true 时,git 存储库始终以 LF 行结束格式存储文件,客户端文件中的行结束在客户端(即 Windows) checkout /提交时来回转换使用非 LF 行尾,无论客户端上的行尾文件是什么格式(这与 Tim Clem 的定义不一致 - 请参阅下面的更新)。
这是一个矩阵,它试图用问号记录 core.autocrlf 的“输入”和“假”设置,其中我不确定行结束转换行为。
我的问题是:
随着共识似乎形成,我将更新答案中的问号。
core.autocrlf value true input false----------------------------------------------------------commit | convert ? ?new | to LF (convert to LF?) (no conversion?)commit | convert to ? no existing | LF (convert to LF?) conversioncheckout | convert to ? noexisting | CRLF (no conversion?) conversion
我并不是真的在寻找关于各种设置的优缺点的意见。我只是在寻找数据,这些数据可以清楚地说明如何期望 git 使用三种设置中的每一种进行操作。
--
2012 年 4 月 17 日更新:阅读后the article by Tim Clem JJD 在评论中链接,我修改了上表中“未知”值中的一些值,以及更改“checkout existing | true 以转换为 CRLF 而不是转换为客户端”。以下是他给出的定义,比我在其他地方看到的任何定义都清晰:
core.autocrlf = false
This is the default, but most people are encouraged to change thisimmediately. The result of using false is that Git doesn’t ever messwith line endings on your file. You can check in files with LF or CRLFor CR or some random mix of those three and Git does not care. Thiscan make diffs harder to read and merges more difficult. Most peopleworking in a Unix/Linux world use this value because they don’t haveCRLF problems and they don’t need Git to be doing extra work wheneverfiles are written to the object database or written out into theworking directory.
core.autocrlf = true
This means that Git will process all text files and make sure thatCRLF is replaced with LF when writing that file to the object databaseand turn all LF back into CRLF when writing out into the workingdirectory. This is the recommended setting on Windows because itensures that your repository can be used on other platforms whileretaining CRLF in your working directory.
core.autocrlf = 输入
This means that Git will process all text files and make sure thatCRLF is replaced with LF when writing that file to the objectdatabase. It will not, however, do the reverse. When you read filesback out of the object database and write them into the workingdirectory they will still have LFs to denote the end of line. Thissetting is generally used on Unix/Linux/OS X to prevent CRLFs fromgetting written into the repository. The idea being that if you pastedcode from a web browser and accidentally got CRLFs into one of yourfiles, Git would make sure they were replaced with LFs when you wroteto the object database.
Tim 的文章非常好,我唯一能想到的是他假设存储库是 LF 格式,这不一定是正确的,尤其是对于仅限 Windows 的项目。
将 Tim 的文章与投票最高的文章进行比较 answer to date by jmlane 在 true 和 input 设置上完全一致,在 false 设置上存在分歧。
最佳答案
关于 core.autocrlf
工作原理的最佳解释可以在 gitattributes 上找到。手册页,在 text
attribute section .
这就是 core.autocrlf
当前的工作方式(或者至少从我所知的 v1.7.2 开始):
core.autocrlf = true
LF
字符的文本文件在您的工作树中被规范化为 CRLF
;存储库中包含 CRLF
的文件将不会被触及LF
字符的文本文件在提交回存储库时从 CRLF
规范化为 LF
。存储库中包含 CRLF
的文件将不受影响地提交。core.autocrlf = input
CRLF
字符的文本文件在提交回存储库时被规范化为 LF
。core.autocrlf = false
core.eol
指示工作树的文本文件中的 EOL 字符。core.eol = native
默认情况下,这意味着工作树 EOL 将取决于 git 运行的位置:Windows 机器上的 CRLF
,或 LF
在 *nix 中。gitattributes
设置确定提交到存储库的 EOL 字符规范化(默认是规范化为 LF
字符)。我最近才研究这个问题,我也觉得情况很复杂。 core.eol
设置无疑有助于阐明 git 如何处理 EOL 字符。
关于git - 不同操作系统之间的行结束转换如何与 git core.autocrlf 一起工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3206843/
我正在编写一个类,我想知道哪一对方法更适合描述流程周期: start() -> stop() start() -> end() start() -> finish() 基本上这些方法将在执行任务之前和
对于 Android 小部件类名称是否应以“View”、“Layout”或两者都不结尾,是否存在模式或命名约定? 最佳答案 如果该类扩展了 View(或在其层次结构中扩展了 View),那么它应该以“
我正在尝试找到一个插件,该插件将使用 Verilog 突出显示匹配的开始/结束语句。 VIM 让它与花括号/括号一起工作,但它不能与它的开始/结束一起工作。我希望 VIM 突出显示正确的开始到正确的结
给出以下代码: % Generate some random data n = 10; A = cell(n, 1); for i=1:n A{i} = timeseries; A{i
我需要知道是否可以检测输入何时开始聚焦以及何时结束焦点 HTML 代码: JQuery 代码(仅示例我如何需要它): $('.datas').on('focusStart', alert("fo
所以我一直在思考一款游戏的想法,一款需要穿越时空的游戏。因此,我编写了一个 JFrame 来显示螺旋的 .gif,但它并没有在对话框显示时结束,而是保留在后台。我可以解决这个问题吗? import j
给出以下使用多线程的 Java 示例: import java.util.concurrent.*; public class SquareCalculator { private Ex
好吧,我有一个 do-while 循环,应该在使用点击“q”时结束,但它给了我错误消息,请帮忙。 package Assignments; import java.util.*; public cla
我如何有选择地匹配开始 ^或结束 $正则表达式中的一行? 例如: /(?\\1', $str); 我的字符串开头和结尾处的粗体边缘情况没有被匹配。我在使用其他变体时遇到的一些极端情况包括字符串内匹配、
我试图让程序在总数达到 10 时结束,但由于某种原因,我的 while 循环在达到 10 时继续计数。一旦回答了 10 个问题,我就有 int 百分比来查找百分比。 import java.util.
jQuery 中的 end() 函数将元素集恢复到上次破坏性更改之前的状态,因此我可以看到它应该如何使用,但我已经看到了一些代码示例,例如:on alistapart (可能来自旧版本的 jQuery
这个问题在这里已经有了答案: How to check if a string "StartsWith" another string? (18 个答案) 关闭 9 年前。 var file =
我正在尝试在 travis 上设置两个数据库,但它只是在 before_install 声明的中途停止: (END) No output has been received in the last 1
我创建了一个简单的存储过程,它循环遍历一个表的行并将它们插入到另一个表中。由于某种原因,END WHILE 循环抛出缺少分号错误。所有代码对我来说都是正确的,并且所有分隔符都设置正确。我只是不明白为什
您好,我正在使用 AVSpeechSynthesizer 和 AVSpeechUtterance 构建一个 iOS 7 应用程序,我想弄清楚合成何时完成。更具体地说,我想在合成结束时更改播放/暂停按钮
这是我的代码,我试图在响应后显示警报。但没有显示操作系统警报 string filepath = ConfigurationManager.AppSettings["USPPath"].ToStri
我想创建一个循环,在提供的时间段、第一天和最后一天返回每个月(考虑到月份在第 28-31 天结束):(“function_to_increase_month”尚未定义) for beg in pd.d
我目前正在用 Python 3.6 为一个骰子游戏编写代码,我知道我的编码在这方面有点不对劲,但是,我真的只是想知道如何开始我的 while 循环。游戏说明如下…… 人类玩家与计算机对战。 玩家 1
所以我已经了解了如何打开 fragment。这是我的困境。我的 view 旁边有一个元素列表(元素周期表元素)。当您选择一个元素时,它会显示它的信息。 我的问题是我需要能够从(我们称之为详细信息 fr
我想检测用户何时停止滚动页面/元素。这可能很棘手,因为最近对 OSX 滚动行为的增强创造了这种新的惯性效应。是否触发了事件? 我能想到的唯一其他解决方案是在页面/元素的滚动位置不再改变时使用间隔来拾取
我是一名优秀的程序员,十分优秀!