How to cherry-pick a commit that has more than one parent?

2.2k views Asked by At

I am writing an application that automates the re-building of a branch based on a new head. It uses cherry-picking to get the job done, but many times the app runs into merge commits that have 2 parents. When I do:

_ngit.CherryPick().Include(commit).Call();

...it throws an exception, Cannot cherry-pick commit '{commit_id}' because it has 2 parents, only commits with exactly one parent are supported.

I need the ability to cherry-pick these merge commits, selecting the first parent as the base. Seems like there would be something like:

_ngit.CherryPick().Include(commit).WithBase(0).Call(); (where 0 is the index of the first parent that I want to use as a base)

I've seen various hints on the web where people trying to get this ability added to jgit, but I've never seen any documentation or anything in the API that suggests it's available. Some such "hints" are:

If this is possible with jgit, please tell me how. If there's another way to get these merge commits added into my new branch, I'm all ears.

0

There are 0 answers