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

后端 未结 6 1758
无人及你
无人及你 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:38

    A cherry-pick is basically a commit, so if you want to undo it, you just undo the commit.

    when I have other local changes

    Stash your current changes so you can reapply them after resetting the commit.

    $ git stash
    $ git reset --hard HEAD^
    $ git stash pop  # or `git stash apply`, if you want to keep the changeset in the stash
    

    when I have no other local changes

    $ git reset --hard HEAD^
    

提交回复
热议问题