Abort a git cherry-pick?

265,438

Solution 1

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

Solution 2

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

git reset --hard HEAD

Solution 3

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.

Share:
265,438
agmin
Author by

agmin

Software developer in Seattle

Updated on July 08, 2022

Comments

  • agmin
    agmin almost 2 years

    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?

  • x-yuri
    x-yuri almost 10 years
    Is it any different from git reset --hard? I'm using rebase workflow, if anything. It seems to work out for me.
  • ffghfgh
    ffghfgh over 8 years
    what's the difference between --merge and --abort?
  • Kaz
    Kaz over 4 years
    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.
  • BJYC
    BJYC over 4 years
    True, it doesn't give me any error, but not not completely quitting the command state.
  • martinkunev
    martinkunev over 4 years
    This doesn't answer the question and only suggests an operation likely to destroy data.
  • deed02392
    deed02392 almost 4 years
    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.