git 如何使用 egit 删除提交?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13534336/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to delete commits with egit?
提问by stommestack
I just made some bad commits with egit that I would like to delete.
我刚刚用 egit 做了一些我想删除的错误提交。
How do I delete commits from egit?
如何从 egit 中删除提交?
Thanks!
谢谢!
EDIT: I tried a hard reset a few times but it didn't do anything.
编辑:我尝试了几次硬重置,但没有做任何事情。
EDIT 2: Hard reset does rollback changes indeed, but I want them to completely disappear from the history as if I never made these commits.
编辑 2:硬重置确实会回滚更改,但我希望它们从历史记录中完全消失,就好像我从未进行过这些提交一样。
回答by Frank
RightMouse on your Repository and click on "show in -> history". You should select the last commit before your last "fetch"...most of the time its the second commit under your current HEAD. RightMouse on that commit and "reset -> Hard" (will reset all your commits AND local workspace changes to the selected commit).
RightMouse 在您的存储库上,然后单击“显示在 - > 历史记录”。您应该选择最后一次“获取”之前的最后一次提交……大多数情况下它是您当前 HEAD 下的第二次提交。在该提交上使用 RightMouse 并“重置 -> 硬”(将您的所有提交和本地工作区更改重置为所选提交)。
you should see the up-arrow changing into an down-arrow, meaning that your commits are deleted and that your repository is outdated. Use "fetch" & "rebase" to be up to date.
您应该会看到向上箭头变为向下箭头,这意味着您的提交已被删除并且您的存储库已过时。使用“fetch”和“rebase”来保持最新。
回答by VonC
Note that Egit3.0 in Keplerallows you to hard reset to any treeish expression you want:
请注意,开普勒中的Egit3.0允许您硬重置为您想要的任何树状表达式:
But once hard reset, you still need to git push --force
after that: if you don't the history of your upstream repo would still list that commit.
但是一旦硬重置,您仍然需要git push --force
在那之后:如果您不这样做,上游存储库的历史记录仍会列出该提交。
回答by damiankolasa
You can do a hard reset but be carefull with that !! Here's some more info: Delete commits from a branch in Git
您可以进行硬重置,但要小心!这是更多信息:从 Git 中的分支删除提交