【问题标题】:git cherry-pick and ignoring eol typegit cherry-pick 并忽略 eol 类型
【发布时间】:2013-08-13 12:32:42
【问题描述】:

出于某种完全奇怪的原因,我的 git 存储库中有一个混合行结尾的文件。 (至少这是git diff 声称的,即使所有提交都是在core.autocrlf 选项设置为true 的情况下完成的。)当我尝试挑选一个提交时,由于这些行结尾而失败:

$ git status
# On branch master
nothing to commit, working directory clean
$ git cherry-pick 77fe281
error: could not apply 77fe281... TFS changeset 9148
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
$ git status
# On branch master
# You are currently cherry-picking.
#   (fix conflicts and run "git commit")
#
# Changes to be committed:
#
#       modified:   some/other/file.txt
#
# Unmerged paths:
#   (use "git add <file>..." to mark resolution)
#
#       both modified:      Builds/rakefile.rb
#
$ cat Builds/rakefile.rb |grep "<<<"
<<<<<<< HEAD
$ git cherry-pick --abort

正如您在此处看到的,Builds/rakefile.rb 文件中存在冲突。顺便说一句,git 声称这两个文件中的所有行都不同,可能是由于这些不同的行结尾。但至少 git 在这里是一致的。

但是让我们尝试使用 ignore-all-space 选项:

$ git status
# On branch master
nothing to commit, working directory clean
$ git cherry-pick 77fe281 --strategy recursive -Xignore-all-space
error: addinfo_cache failed for path 'Builds/rakefile.rb'
U       Builds/rakefile.rb
error: 'commit' is not possible because you have unmerged files.
hint: Fix them up in the work tree,
hint: and then use 'git add/rm <file>' as
hint: appropriate to mark resolution and make a commit,
hint: or use 'git commit -a'.
fatal: Exiting because of an unresolved conflict.
$ git status
# On branch master
# You are currently cherry-picking.
#   (fix conflicts and run "git commit")
#
# Changes to be committed:
#
#       modified:   some/other/file.txt
#
# Unmerged paths:
#   (use "git add <file>..." to mark resolution)
#
#       both modified:      Builds/rakefile.rb
#
$ cat Builds/rakefile.rb |grep "<<<"
$

这里 git 声称它无法合并文件,但文件实际上已合并(并且正确!)。我做错了什么?

(咆哮:git 实际上是第一个迫使我像在 1960 年代一样照顾 eol 的 VCS)

【问题讨论】:

    标签: git eol


    【解决方案1】:

    这并没有回答为什么它认为存在冲突,但只是对于其他可能想知道如何用cherry-pick 忽略行尾的人,你的建议是:

    git cherry-pick a1b2c3d --strategy recursive -Xignore-all-space

    完全符合我的要求。

    【讨论】:

    • 我遇到了类似的问题,但 ignore-all-space 对我不起作用。我必须指定renormalize,这样就成功了。
    猜你喜欢
    • 2012-07-23
    • 2018-07-27
    • 2010-11-17
    • 2018-10-04
    • 1970-01-01
    • 1970-01-01
    • 2013-11-18
    • 2012-06-24
    • 2011-10-27
    相关资源
    最近更新 更多