使用Mercurial,如果你commit,你能回到commit之前的原始状态吗?

发布于 2024-09-05 22:25:57 字数 175 浏览 5 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

人海汹涌 2024-09-12 22:25:57

hg rollback 完全符合您的要求 - 它会撤消 hg commit 并且您最终会处于提交之前的状态。

当然,版本控制系统并不是真的想要“丢失”您已经提交的版本,但是恢复意外提交很方便。

hg rollback does exactly what you are asking for - it undoes the hg 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.

安人多梦 2024-09-12 22:25:57

当然,一旦你推动,就没有任何工具可以满足你的要求。话虽这么说,如果您想要从本地历史记录中删除多个变更列表,而不是仅仅使用 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 use hg 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文