git cherry-pick和忽略eol类型

时间:2013-08-13 12:32:43

标签: git eol

出于一些完全奇怪的原因,我在我的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文件中存在冲突。 BTW,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声称它无法合并文件,但文件实际上是合并的(并且正确!)。我做错了什么?

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

1 个答案:

答案 0 :(得分:1)

这并没有回答为什么它认为存在冲突,而只是为了那些可能想知道如何用樱桃挑选忽略行结尾的人,你的建议:

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

正是我正在寻找的。