Mercurial:取消最后的更改以便代码库干净?
我刚刚在 Mercurial 中搞砸了一些事情。
我如何取消最后的更改以使代码库干净 - 特别是如果其他人执行“hg pull”,他们将拥有一个可用的代码库?
I've just messed something up in Mercurial.
How do I back out the last change so that the codebase is clean - specifically so that if someone else does 'hg pull', they'll have a working codebase?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
两种方式:
hg rollback
正如 Fred 提到的;如果你已经推动了,那就太晚了。hg rollback
仅适合本地使用。hg strip
(也如 Fred 所提到的)的工作方式相同,并且(除了它对备份的支持之外)相当于多次执行hg rollback
,直到你得到回到那个修订版。hg backout
适用于当您已经推送并且只想恢复提交的效果时(如果您不小心推送了敏感数据,则需要采取更多措施)严厉的措施,但如果你只是想让它发挥作用,请使用这个)。如果提交不是最后提交的修订版,请这么说,我们可以进入更深入的内容(或搜索 - 之前已经回答过)。
Two ways:
hg rollback
as mentioned by Fred; if you've already pushed, too late.hg rollback
is only suitable for local use.hg strip
(also as mentioned by Fred) works the same way and is (excepting its support for backing up) equivalent to doinghg rollback
a number of times, till you get back to that revision.hg backout
for when you have already pushed and just want to revert the effects of the commit (if you've accidentally pushed out sensitive data, you'll need to take more drastic measures, but if you just want it to work, use this).If the commit is not the last-committed revision, say so and we can get into deeper stuff (or search - it's been answered before).
另一种方法是从特定版本克隆。说 checkin 6 是错误的。您可以将存储库克隆到修订版 5:
现在在
myrepoclean
中,您将回到错误签入之前的位置。显然,您需要意识到,任何拉出错误签入的人现在都有可能将其推回。Another way is to clone from a specific revision. Say checkin 6 was the mistake. You can clone your repository up to revision 5:
now in
myrepoclean
you are back to where you were before the bad checkin. Obviously you need to be aware that anyone who has pulled the bad checkin is now liable to push it back in.您还应该查看 strip 命令。
You should also look at the strip command.