Undo a changeAlways fixable

Undo a cherry-pick

How do I undo a git cherry-pick?

Short answer

If it's still in progress, git cherry-pick --abort restores everything. If it completed, git reset --hard HEAD~1 removes the resulting commit — or git revert it if you've already pushed.

quick fix
git cherry-pick --abort

Cancels an in-progress cherry-pick and restores the previous state

Does this match your situation?

  • You cherry-picked the wrong commit.
  • A cherry-pick stopped with conflicts you don't want to resolve.
  • The picked commit brought in changes that don't belong on this branch.

Step-by-step fix

  1. Still mid-cherry-pick? Abort

    If conflicts stopped it and no commit was created, aborting rewinds everything to before you started. Nothing is lost.

    step 1
    git cherry-pick --abort
    
  2. Skip just one commit of a range

    When picking a range and only one commit is a problem, skip that one and let the rest continue.

    step 2
    git cherry-pick --skip
    
  3. Completed but not pushed? Reset it away

    A finished cherry-pick is an ordinary commit at the tip of your branch, so removing it is an ordinary reset.

    step 3
    git log --oneline -3
    git reset --hard HEAD~1
    
    # picked several? go back that many:
    git reset --hard HEAD~3
    

    --hard discards uncommitted changes too. Stash first if you have any.

  4. Already pushed? Revert instead

    On a shared branch, add a commit that undoes the change rather than rewriting what others have already pulled.

    step 4
    git revert HEAD
    git push
    
  5. Recover if you reset too far

    The reflog has every position your branch held, so an over-eager reset is a one-line fix.

    step 5
    git reflog
    git reset --hard HEAD@{1}
    

Why this works

Cherry-pick creates a brand-new commit that happens to contain the same changes as another one — it is not a link or a reference to the original. That means the result is structurally indistinguishable from a commit you wrote by hand, and every ordinary undo applies: abort while it's in progress, reset while it's private, revert once it's public. The original commit on its own branch is never affected by any of this.

How to stop it happening again

  • Check the commit before picking it: git show <hash>.
  • Use -n to stage without committing, so you can inspect the result first.
  • Prefer merging or rebasing whole branches when you want everything — cherry-picking is for isolated commits.

Commands used in this guide

git cherry-pick

Copy one specific commit onto your current branch.

git reset

Move the current branch pointer, optionally rewriting the index and your files.

git revert

Create a new commit that undoes an earlier one, leaving history intact.

git reflog

The undo history for everything - the single most important recovery command.

Still stuck?

Search the full command reference and every other rescue guide — there are 56 of them, covering everything from detached HEAD to force-push disasters.

Browse all guides →

Frequently asked questions

How do I cancel a cherry-pick in progress?

git cherry-pick --abort. It restores your branch and working directory to exactly the state before the cherry-pick began, discarding any partial conflict resolution.

How do I remove a commit created by a cherry-pick?

If it hasn't been pushed, git reset --hard HEAD~1 drops it. If it has been pushed to a branch others use, git revert HEAD instead so history stays valid for everyone.

Does undoing a cherry-pick affect the original commit?

No. Cherry-pick copies the change into a new commit with a different hash; the original stays untouched on its own branch and can be picked again later.

Related rescue guides

← All Git Rescue guides