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
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.
-
8Has 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.– danns87Commented 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?– user456814Commented Oct 30, 2013 at 19:38 -
7yes, 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! Commented Jun 4, 2014 at 12:02 -
@KumarHarsh which version of Git are you using?– user456814Commented 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. Commented Jun 4, 2014 at 20:10
I found the answer is git reset --merge
- it clears the conflicted cherry-pick attempt.
-
4Is it any different from
git reset --hard
? I'm using rebase workflow, if anything. It seems to work out for me.– x-yuriCommented Aug 22, 2014 at 10:03 -
4
For me, the only way to reset the failed cherry-pick-attempt was
git reset --hard HEAD
-
4This doesn't answer the question and only suggests an operation likely to destroy data. Commented Jan 31, 2020 at 9:43
-
1If 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. Commented Jun 30, 2020 at 9:41
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.
-
1That shouldn't exist. Git is complicated enough without two ways of canceling a cherry pick that have subtly different effects on the repo state.– KazCommented Oct 21, 2019 at 19:25
-
True, it doesn't give me any error, but not not completely quitting the command state.– BJYCCommented Oct 21, 2019 at 19:35