On a local repo, I\'ve just executed git cherry-pick SHA
without any conflicts or problems. I then realized I didn\'t want to do what I just did. I have not pushed
If possible, avoid hard resets. Hard resets are one of the very few destructive operations in git. Luckily, you can undo a cherry-pick without resets and avoid anything destructive.
Note the hash of the cherry-pick you want to undo, say it is ${bad_cherrypick}
. Do a git revert ${bad_cherrypick}
. Now the contents of your working tree are as they were before your bad cherry-pick.
Repeat your git cherry-pick ${wanted_commit}
, and when you're happy with the new cherry-pick, do a git rebase -i ${bad_cherrypick}~1
. During the rebase, delete both ${bad_cherrypick}
and its corresponding revert.
The branch you are working on will only have the good cherry-pick. No resets needed!