Do a cherry pick via the api


I would like to do a cherry pick via the GitHub API. I know that cherry picking is not directly implemented there. 

Is there a way to do it with the methods that are available?

I found something (scrolling down to the Step by Step section). This uses only available API operations. Is this a “legit” way to do it, because I did not get it to work as expected, it is always taking all the commits from the branch where the commit I want to cherry pick is. 

I need to do it via the API because I need it in an Java-Application. 

Thank you very much. Every help is more than welcome.

Hello again,

i got it working. 

Now another problem came up:

When I do a merge via the GitHub API (one of the Steps to do a cherry pick via the API according to the link provided aboive) and there is a merge error I got a 409 error, which is perfectly fine but the changes do not get merged.

What I want to achieve is that it shows the conflict markers <<<<<<< and >>>>>>>

Like in a “real” cherry pick.

Is that somehow possible? 

Thank you.

would it be possible to get support for cherry-pick thought the GitHub REST API in the same manner as for merge (Repositories - GitHub Docs). To get a handle like:

POST /repos/{owner}/{repo}/cherry-picks

Thank you.

1 Like

Hi @molama and @petricm :wave:

Interestingly, we recently added cherry pick functionality to our Desktop client:

But for an official endpoint, it would be best if either or both (preferably both) of you could submit your suggestion directly via our feedback form:

These submissions get reviewed for consideration directly by our PM teams.

In the meantime, while we don’t have an official endpoint for cherry picking commits, there are custom built solutions out there, like in the OP here. Though as our OP discovered, there might be difficulties in getting those custom solutions to function.

Since they are not officially authored by GitHub, our staff can’t assist with troubleshooting those steps.

Have opened a request via the feedback form and encourage whoever reads this thread to do the same.

1 Like