Abort a git cherry-pick?

GitGit Cherry-Pick

Git Problem Overview


I ran git cherry-pick <hash> and had merge conflicts. I don't want to resolve the conflicts, I just want to abort the cherry-pick. When doing an actual merge (with git merge) there's the handy git merge --abort. What's the equivalent for cherry-picking?

Git Solutions


Solution 1 - Git

You can do the following

git cherry-pick --abort

From the git cherry-pick docs

> --abort
> Cancel the operation and return to the pre-sequence state.

Solution 2 - Git

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

Solution 3 - Git

For me, the only way to reset the failed cherry-pick-attempt was

git reset --hard HEAD

Solution 4 - Git

Try also with '--quit' option, which allows you to abort the current operation and further clear the sequencer state.

> --quit > Forget about the current operation in progress. Can be used to clear the sequencer state after a failed cherry-pick or revert.

> --abort > Cancel the operation and return to the pre-sequence state.

use help to see the original doc with more details, $ git help cherry-pick

I would avoid 'git reset --hard HEAD' that is too harsh and you might ended up doing some manual work.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionagminView Question on Stackoverflow
Solution 1 - Gituser456814View Answer on Stackoverflow
Solution 2 - GitagminView Answer on Stackoverflow
Solution 3 - GitDiego P. SteinerView Answer on Stackoverflow
Solution 4 - GitBJYCView Answer on Stackoverflow