HG: Undo a commit from history

时光毁灭记忆、已成空白 提交于 2019-12-03 08:16:55

问题


I have a HG repository with revs 1, 2, 3, 4, 5 and 6.

When I committed rev 4, I unknowingly botched some changes in rev3 that I should not have. I did not notice this until rev 6 was already committed.

I need to undo changes in rev 4, but then re-apply all other changes after that. Basically undoing commit #4. How can I do that?


回答1:


You want hg backout

Revert/undo the effect of an earlier changeset...

Backout works by applying a changeset that's the opposite of the changeset to be backed out. That new changeset is committed to the repository, and eventually merged...




回答2:


You can use the MQ extension:

hg qinit
hg qimport -r 4:tip
hg qpop -a
hg qdelete 4.diff
hg qpush -a
hg qfinish -a

The above is how you rewrite history, which is what you want I believe.

You can also use hg backout but that undoes a commit in your working directory and you can commit that.



来源:https://stackoverflow.com/questions/5913424/hg-undo-a-commit-from-history

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!