简体   繁体   English

如何撤消'git commit'

[英]How to undo 'git commit'

I would like to undo the last Git action, git commit . 我想撤消上一个Git操作git commit

I would like to see it completely gone from history. 我希望看到它完全脱离历史。 I would also like to have all the included changes as local changes in my working copy, so later they can be committed. 我还希望将所有包含的更改作为我的工作副本中的本地更改,以便以后可以提交。

Nothing is pushed yet. 什么都没有推。

What I dont want: 想要的:

  • git revert - that will just create an other commit that contains the negative of my erroneous commit which I should not have made in the first place git revert只会创建一个其他提交,其中包含我不应该首先提交的错误提交的否定项
  • git reset --hard OR --soft - that will not convert the changes from the commit back to local changes, only leave there what I still have uncommitted (with --soft) git reset --hard--soft不会将更改从提交转换回本地更改,只保留我仍未提交的内容(使用--soft)

运行git reset --soft将从历史记录中删除提交,但将更改保留在工作副本中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM