How to undo a successful “git cherry-pick”?

后端 未结 6 1770
无人及你
无人及你 2021-01-30 02:12

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

6条回答
  •  天涯浪人
    2021-01-30 02:31

    To undo your last commit, simply do git reset --hard HEAD~.

    Edit: this answer applied to an earlier version of the question that did not mention preserving local changes; the accepted answer from Tim is indeed the correct one. Thanks to qwertzguy for the heads up.

提交回复
热议问题