git - 何时将 --keep-cr 与 am 一起使用以及它是在哪个版本的 git 中引入的?

标签 git line-endings core.autocrlf format-patch git-am

我正在尝试为我们的组织制定正式的补丁工作流程。我们有一个内部项目,我们不介意空格(如果可能的话,希望对每个用户保持相同)、EOF/EOL 字符等。我们有在 Mac 和 Windows 平台上工作的开发人员。在这两个地方,我们都使用 git 和 Cygwin。

read here core.autocrlf true 可以解决问题,或者您可以使用 --keep-cr 。 但是here VonC suggests core.autocrlf false是一个更好的策略。

我的问题是:

  1. 何时使用 true,何时使用 false? (我只是不想让 git 打扰我 并且补丁应涂抹光滑)。
  2. --keep-cr 何时引入?我使用 git 1.7.2,我的手册页没有这个选项?
  3. 使用哪些忽略空白选项才能实现顺利的修补工作流程?

最佳答案

1.7.2 应该有 git am 的 --keep-cr,因为它是在 commit ad2c928 中引入的。作者:Stefan-W. Hahn,包含在 Git 1.7.1 中。

when you know you are feeding output from "git format-patch" directly to "git am", and especially when your contents have CR at the end of line, such stripping is undesirable. To help such a use case, teach --keep-cr option to "git am" and pass that to "git mailinfo".

但是,在 Windows 上,我总是使用 latest Git For Windows release , not the cygwin one (尽管you can have both)。

core.autocrlf is that it is a repository-wide setting 的问题这可能会影响所有文件(甚至是非文本文件)。
我更喜欢core.eol directives .

对于空格,您可以尝试“git: patch does not apply ”:

git apply --ignore-space-change --ignore-whitespace mychanges.patch

关于git - 何时将 --keep-cr 与 am 一起使用以及它是在哪个版本的 git 中引入的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24178587/

相关文章:

swift - PNChart-swift 不工作

git - Force SourceTree 忽略 git 文件中的行结尾

Git commit 忽略行尾

git - .gitattributes 使用 '* text=auto' 和过滤器

git - 强制所有行尾到LF的git

node.js - 在 Windows 机器上工作时使用 unix 行结尾有什么副作用吗?

linux - Git 存档行结尾与克隆不同

git - 我需要哪些信息来证明我的整个 Git 存储库的完整性?

ios - firebase3在Swift中的集成面临问题

git - 是否有 svn :bugtraq properties? 的 Git 副本