首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >git cherry-pick和忽略eol类型

git cherry-pick和忽略eol类型
EN

Stack Overflow用户
提问于 2013-08-13 20:32:43
回答 1查看 1.5K关注 0票数 3

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

代码语言:javascript
复制
$ 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选项来尝试同样的方法:

代码语言:javascript
复制
$ 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实际上是第一个迫使我像60年代那样处理eol的VCS )

EN

回答 1

Stack Overflow用户

发布于 2014-11-05 19:16:27

这并不能解释为什么它认为存在冲突,但对于其他可能想知道如何用cherry-pick忽略行尾的人来说,你的建议是:

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

做了我想要的。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18209198

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档