When you try to cherry-pick a commit that is already in the current branch, the message
The previous cherry-pick is now empty, possibly due to conflict resolution.
will be shown.
The meaning of that is clear.
However, the message clearly covers some other situation and I don't understand the other case - possibly due to conflict resolution. How can a conflict resolution make a commit empty?
git cherry-pick <commit-hash> to cherry-pick a commit from another branch. git cherry-pick -n <commit-hash> to cherry-pick the commit but it won't commit the changes. It will only stage all the changes. git cherry-pick —continue or git cherry-pick —abort when you face conflicts while cherry-picking.
You cannot cherry-pick while there are conflicts. Furthermore, in general conflicts get harder to resolve the more you have, so it's generally better to resolve them one by one. That said, you can cherry-pick multiple commits at once, which would do what you are asking for.
I found the answer is git reset --merge - it clears the conflicted cherry-pick attempt.
It's exactly what it says: the changes you're trying to cherry-pick are already wholly contained in the branch you're on. I.e. the result of the cherry-pick is no changes. You can create an empty commit with the --allow-empty flag to indicate that you attempted to cherry-pick, but there were no changes to pull in.
When you cherry pick a commit, git tries to apply a patch. Three outcomes are possible:
If there are conflicts in files, you can edit them, called "conflict resolution". One way of editing them is to remove all the changes that the cherry-pick would have added. When you do so, you end up with no more changes anywhere, but still the cherry-pick being in progress. That's why this hint says "possibly due to conflict resolution".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With