git cherry-pick --abort
This command is useful when a cherry-pick ran into conflicts or went wrong and you want to completely back out and return your working tree and index to how they were before starting the cherry-pick operation.
This command tells Git to stop the ongoing cherry-pick sequence and roll back all changes that were staged or applied during that operation, restoring both the index (staging area) and the working directory to the snapshot recorded right before the cherry-pick began; the --abort flag specifically instructs Git to abandon the cherry-pick instead of trying to continue or skip commits.
In addition to this command, you can use git cherry-pick --continue after resolving conflicts to resume an interrupted cherry-pick, or git cherry-pick --skip to ignore the current problematic commit and move on to the next one in a series; related commands like git revert <commit> create a new commit that undoes another commit (instead of replaying it), and git reset --hard HEAD can also discard local changes, but unlike this command it is not limited to just undoing a cherry-pick sequence and can be more destructive if used carelessly.
Examples:
git cherry-pick --abort- After conflicts during
git cherry-pick abc123, use:git cherry-pick --abort