608

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 of cherry-picking?

4 Answers 4

947

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.

8
  • 8
    Has the --abort option been removed/added in a specific git version? I'm running git 1.7.4.1 and "git cherry-pick --abort" results in a git cherry-pick usage message. I also grepped "git help cherry-pick" for "abort" and didn't find anything.
    – danns87
    Commented Oct 30, 2013 at 18:57
  • 2
    @danns87 the --abort option became available at version 1.7.8. Is it possible for you to upgrade?
    – user456814
    Commented Oct 30, 2013 at 19:38
  • 7
    yes, this doesn't work. Most of the times I get this error: Entry '<unstaged file>' not uptodate. Cannot merge. On the other hand, git reset --merge does work!
    – kumarharsh
    Commented Jun 4, 2014 at 12:02
  • @KumarHarsh which version of Git are you using?
    – user456814
    Commented Jun 4, 2014 at 12:03
  • 1
    >1.8. Actually, it was because of dirty files in the directory. But the git reset --merge command works even then.
    – kumarharsh
    Commented Jun 4, 2014 at 20:10
104

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

2
  • 4
    Is it any different from git reset --hard? I'm using rebase workflow, if anything. It seems to work out for me.
    – x-yuri
    Commented Aug 22, 2014 at 10:03
  • 4
    what's the difference between --merge and --abort?
    – ffghfgh
    Commented Feb 12, 2016 at 15:19
25

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

git reset --hard HEAD
2
  • 4
    This doesn't answer the question and only suggests an operation likely to destroy data. Commented Jan 31, 2020 at 9:43
  • 1
    If your cherry-pick succeeded and you actually just want to revert the changes made by it, then this is the right answer, but be warned that it will lose any other changes you've made, not just ones due to the cherry-pick.
    – deed02392
    Commented Jun 30, 2020 at 9:41
12

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.

2
  • 1
    That shouldn't exist. Git is complicated enough without two ways of canceling a cherry pick that have subtly different effects on the repo state.
    – Kaz
    Commented Oct 21, 2019 at 19:25
  • True, it doesn't give me any error, but not not completely quitting the command state.
    – BJYC
    Commented Oct 21, 2019 at 19:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.