Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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:".

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

$ 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.

like image 798
Torsten Bronger Avatar asked Aug 24 '14 12:08

Torsten Bronger


People also ask

Is it possible to cherry pick multiple commits?

Cherry-Picking Multiple Commits Instead, it's possible to provide multiple commits, or even a range, as arguments for the command. The result of the command above would be two new commits with the same changes and content of the original commits from new.

How do you fix cherry pick conflict?

One possible way to avoid these cherry-pick conflicts is by doing the cherry-picking in the order of oldest commit to latest commit, i.e. based on commit date.

How do you cherry pick multiple squash commits?

Suppose you have a series of commits you want to cherry-pick and squash onto another branch. The traditional way of doing this is to cherry-pick the series of commits with the -n option so that they all stack on top of each other, and then perform a big git commit when you're done.

How do you cherry pick multiple commits in TFS?

In the Branches view, right-click the target branch and choose Checkout. In the Branches view, right-click the source branch and choose View History to open a commit History tab. In the History tab, right-click the commit you want to cherry-pick and choose Cherry-Pick.


1 Answers

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, A should be older than B.
If they're the wrong order the command will silently fail.

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

like image 86
VonC Avatar answered Sep 28 '22 05:09

VonC