如何撤消成功的"git cherry-pick"? [英] How to undo a successful "git cherry-pick"?
问题描述
在本地仓库中,我刚刚执行了git cherry-pick SHA
,没有任何冲突或问题.然后我意识到我不想做我刚刚做的事情.我没有把它推到任何地方.
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 this anywhere.
我怎样才能只删除这个樱桃精选呢?
How can I remove just this cherry pick?
我想知道是否有办法做到这一点:
I'd like to know if there's a way to do this:
- 当我有其他本地更改时
- 当我没有其他本地更改时
如果可能的话,最好在两种情况下都使用一个命令.
Preferably with one command for both cases if possible.
推荐答案
Cherry-pick本质上是一种提交,因此,如果要撤消它,则只需撤消提交即可.
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^
这篇关于如何撤消成功的"git cherry-pick"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!