使用Mercurial,如果你commit,你能回到commit之前的原始状态吗?
hg backout Tip
似乎还会将所有文件恢复到旧版本。有没有办法将其更改回与提交之前完全相同的状态——也就是说,有几个文件“已修改”但未提交——本质上,就好像“提交”从未完成一样?
(hg rollback
据说非常糟糕,通常不应该出于版本控制目的而这样做)
hg backout tip
seem to also revert all your files back to the older version. Is there a way to change it back to EXACTLY like before the commit -- that is, with several files "Modified" but uncommitted -- essentially, as if the "commit" was never done?
(hg rollback
is said to be very bad and usually shouldn't be done for version control purpose)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
hg rollback
完全符合您的要求 - 它会撤消hg commit
并且您最终会处于提交之前的状态。当然,版本控制系统并不是真的想要“丢失”您已经提交的版本,但是恢复意外提交很方便。
hg rollback
does exactly what you are asking for - it undoes thehg commit
and you end up in the state you were before you committed.Of course it's not really in the intention of a version control system to "lose" versions you already committed, but it's handy to revert an accidental commit.
当然,一旦你推动,就没有任何工具可以满足你的要求。话虽这么说,如果您想要从本地历史记录中删除多个变更列表,而不是仅仅使用
hg backout
撤消其影响,那么您可以使用hg strip
,它作为 MQ 扩展包的一部分提供。您可以执行以下操作来获得您想要的效果:
hg export Tip > foo.patch
hg strip Tip
hg import --no-commit foo.patch
Once you push, of course, there is no tool that will do what you want. That being said, if you have more than one changelist that you want to remove from your local history rather than just undoing their effect with
hg backout
, then you can usehg strip
, which is available as part of the MQ extension package.You can do the following to get your desired effect:
hg export tip > foo.patch
hg strip tip
hg import --no-commit foo.patch