3

由于某些完全奇怪的原因,我的 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)

4

1 回答 1

3

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

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

完全符合我的要求。

于 2014-11-05T11:16:26.980 回答