Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "possibly due to conflict resolution" mean in the empty cherry-pick message?

Tags:

git

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?

like image 657
yuranos Avatar asked Feb 09 '17 14:02

yuranos


People also ask

How do I resolve conflicts after git cherry pick?

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.

Can you get much conflict during git cherry pick?

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.

How do you abort cherry picks with conflicts?

I found the answer is git reset --merge - it clears the conflicted cherry-pick attempt.

Why is cherry pick commit empty?

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.


1 Answers

When you cherry pick a commit, git tries to apply a patch. Three outcomes are possible:

  • no change, because the patch was already in ancestors (e.g. when you try to cherry-pick twice)
  • some changes applied
  • conflicts in files

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

like image 51
tkruse Avatar answered Oct 11 '22 12:10

tkruse