我刚刚在Mercurial搞砸了什么。
如何退出最后一次更改,以便代码库是干净的 - 特别是如果其他人'hg pull',他们将拥有一个可用的代码库?
答案 0 :(得分:4)
两种方式:
弗雷德提到的hg rollback
;如果你已经推迟了,为时已晚。 hg rollback
仅适合本地使用。 hg strip
(也是Fred提到的)以相同的方式工作,并且(除了支持备份)相当于多次执行hg rollback
,直到你回到那个版本。
hg backout
,因为当你已经推送并且只想恢复提交的效果时(如果你不小心推出敏感数据,你需要采取更激烈的措施)措施,但如果您只是想让它起作用,请使用此方法。
如果提交不是最后提交的修订版,请说明,我们可以深入研究(或搜索 - 之前已经回答过)。
答案 1 :(得分:2)
另一种方法是从特定修订版中克隆。说签到6是错误的。您可以将存储库克隆到版本5:
hg clone -r 5 myrepobad myrepoclean
现在在myrepoclean
你会回到错误登记前的位置。显然你需要知道,任何已经退出坏账的人现在都有可能将其推回去。
答案 2 :(得分:1)
$ hg rollback --help hg rollback roll back the last transaction (dangerous) This command should be used with care. There is only one level of rollback, and there is no way to undo a rollback. It will also restore the dirstate at the time of the last transaction, losing any dirstate changes since that time. This command does not alter the working directory. ...
您还应该查看strip命令。