Windows 上的 Git 1.6.4 beta (msysgit) - Unix 或 DOS 行终止

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1249932/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 06:51:15  来源:igfitidea点击:

Git 1.6.4 beta on Windows (msysgit) - Unix or DOS line termination

gitmsysgit

提问by Scott Davies

I am installing msysgit 1.6.4 beta on my Win Vista development VPC. An install screen is requesting whether I want to use Unix line termination or DOS line termination. Ordinarily, I'd choose DOS, but the setup text indicates that DOS termination may mean files do not work with all of Git's command line tools. The Unix line termination states "...most [Windows] applications can handle this...".

我正在我的 Win Vista 开发 VPC 上安装 msysgit 1.6.4 beta。安装屏幕要求我使用 Unix 行终止还是 DOS 行终止。通常,我会选择 DOS,但设置文本表明 DOS 终止可能意味着文件无法与所有 Git 命令行工具一起使用。Unix 行终止声明“......大多数 [Windows] 应用程序可以处理这个......”。

Does anyone know which option I should choose to use Git via the shell for my VS 2008 work?

有谁知道我应该选择哪个选项通过 shell 使用 Git 来为我的 VS 2008 工作?

回答by VonC

That settings during the install process of msysgit is actually here to fix the value of the core.autocrlfconfig.

msysgit 安装过程中的设置实际上是为了修复core.autocrlfconfig的值。

core.autocrlf

If true, makes git convert CRLFat the end of lines in text files to LFwhen reading from the filesystem, and convert in reverse when writing to the filesystem.

The variable can be set to 'input', in which case the conversion happens only while reading from the filesystem but files are written out with LFat the end of lines.

Currently, which paths to consider "text" (i.e. be subjected to the autocrlf mechanism) is decided purely based on the contents.

如果为 true,则CRLFLF从文件系统读取时使 git在文本文件的行尾转换为,并在写入文件系统时反向转换。

该变量可以设置为“ input”,在这种情况下,转换仅在从文件系统读取时发生,但文件LF在行尾写出。

目前,考虑“文本”的路径(即受到 autocrlf 机制的约束)纯粹是根据内容来决定的。

I would insist on nottrying to convert anything automagically, the side-effects are just too important (in term of potential merging conflict, especially on distributed development with different environments)

我坚持尝试自动转换任何东西,副作用太重要了(就潜在的合并冲突而言,尤其是在不同环境的分布式开发中)

If your tools can handle Unix-style line termination, you should set them to produce Unix lines, which can then be read by Windows (VS2008, Notepad++, ...) and Unix alike, and can be processed by any 'sh' Git-scripts.

如果您的工具可以处理 Unix 样式的行终止,您应该将它们设置为生成 Unix 行,然后可以被 Windows(VS2008、Notepad++、...)和 Unix 读取,并且可以被任何“sh”Git 处理- 脚本。

But with core.autocrlfset to false, the decision to transform a text line termination will be a voluntary explicit one, not a background invisible side-effect one.

但是core.autocrlf设置为 false 时,转换文本行终止的决定将是自愿明确的,而不是背景不可见的副作用。



See more at "How line ending conversions work with git core.autocrlfbetween different operating systems"

请参阅“行尾转换如何git core.autocrlf在不同操作系统之间工作

                 | Resulting conversion when       | Resulting conversion when 
                 | committing files with various   | checking out FROM repo - 
                 | EOLs INTO repo and              | with mixed files in it and
                 |  core.autocrlf value:           | core.autocrlf value:           
--------------------------------------------------------------------------------
File             | true       | input      | false | true       | input | false
--------------------------------------------------------------------------------
Windows-CRLF     | CRLF -> LF | CRLF -> LF | as-is | as-is      | as-is | as-is
Unix -LF         | as-is      | as-is      | as-is | LF -> CRLF | as-is | as-is
Mac  -CR         | as-is      | as-is      | as-is | as-is      | as-is | as-is
Mixed-CRLF+LF    | as-is      | as-is      | as-is | as-is      | as-is | as-is
Mixed-CRLF+LF+CR | as-is      | as-is      | as-is | as-is      | as-is | as-is

回答by Martin Liversage

Visual Studio 2008 handles Unixline terminations without problems. However, it will try to detect text files with inconsistent line terminations in an attempt to fix these. Notepad on the other hand is not able to properly display Unixtext files.

Visual Studio 2008 可以毫无问题地处理Unix行终止。但是,它会尝试检测具有不一致行终止符的文本文件,以尝试修复这些问题。另一方面,记事本无法正确显示Unix文本文件。