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.