Recently a colleague of mine used the Git Cherry-pick feature to bring one of their commits from one branch of our repository to another. They hit a somewhat complex merge conflict and, in trying to resolve all of the conflicts in the file, they got confused about what needed to be done.
They came to see me with the question: can they cancel their cherry-pick and partial merge, and start over?
The answer is Yes: it is possible to abort a merge or a cherry-pick Git operation.
Most of the time it is not needed; with a little work and human intelligence, the merge conflicts can be resolved without too much trouble. But sometimes, in cases like my colleague faced, a more complex merge winds up confusing the developer, and they want to go back and start over.
On my team, about a quarter of us use Git from the command line, but most - like my colleague in this story - prefer to use the Eclipse Git plug-in. Unfortunately, the user guide for the Eclipse Git
plugin does not specifically mention aborting a Cherry-pick operation.
They came to see me with the question: can they cancel their cherry-pick and partial merge, and start over?
The answer is Yes: it is possible to abort a merge or a cherry-pick Git operation.
Most of the time it is not needed; with a little work and human intelligence, the merge conflicts can be resolved without too much trouble. But sometimes, in cases like my colleague faced, a more complex merge winds up confusing the developer, and they want to go back and start over.
If you use git from the command-line, it’s as
simple as:
git cherry-pick
--abort
or
git reset --merge
But a
Cherry-pick is a particular kind of Merge. And a Merge can be aborted in
Eclipse Git by doing a Hard Reset of the branch.
As shown in the attached image, right-click on the branch and select "Reset..." Then choose Hard reset in the popup dialog:
A little more information is available in the EGit User Guide:
and