为什么 git 的樱桃采摘不止一次提交失败?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25471836/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 10:19:37  来源:igfitidea点击:

Why does git's cherry picking with more than one commit fail?

gitgit-cherry-pick

提问by Torsten Bronger

I try to merge two repos, yielding a flat (aka interleaved) history. I do this along the lines of https://stackoverflow.com/a/14839653/188108, under "History rewrite:".

我尝试合并两个 repos,产生一个平面(又名交错)历史。我按照https://stackoverflow.com/a/14839653/188108 的“历史重写:”下的路线执行此操作。

The two branches to merge are in "master" and "src/master". Then, I write:

要合并的两个分支在“master”和“src/master”中。然后,我写:

$ git checkout --orphan new-master
$ git cherry-pick 9d325d6d 3f4c52ba
error: a cherry-pick or revert is already in progress
hint: try "git cherry-pick (--continue | --quit | --abort)"
fatal: cherry-pick failed
$ git cherry-pick 9d325d6d && git cherry-pick 3f4c52ba
[new-master 10f0277] Initial revision.
 7 files changed, 194 insertions(+)
 create mode 100644 __init__.py
 create mode 100644 manage.py
 create mode 100644 samples/__init__.py
 create mode 100644 samples/models.py
 create mode 100644 samples/views.py
 create mode 100644 settings.py
 create mode 100644 urls.py
[new-master 08e083c] Fixed field name in SixChambersLayer.  Added Sample.current_place.
 1 file changed, 2 insertions(+), 1 deletion(-)

So, why does the first cherry pick command fail, but the split command works? I use git 1.9.1.

那么,为什么第一个cherry pick 命令失败,但split 命令有效?我使用 git 1.9.1。

回答by VonC

Try instead:

试试吧:

git cherry-pick 9d325d6d^..3f4c52ba

As I mentioned in "How to cherry pick a range of commits and merge into another branch":

正如我在“如何挑选一系列提交并合并到另一个分支”中提到的:

In the "cherry-pick A..B" form, Ashould be older than B.
If they're the wrong order the command will silently fail.

If you want to pick the range Bthrough D(inclusive) that would be B^..D.

在“ cherry-pick A..B”形式中,A应该比B.
如果它们的顺序错误,该命令将无声地失败。

如果您想B通过D(包括)选择范围,那就是B^..D.