Mercurial 汞(hg)相当于git重置(--mixed或--soft)

Mercurial 汞(hg)相当于git重置(--mixed或--soft),mercurial,Mercurial,什么是等效的mercurial命令(或工作流) 或 i、 e.我希望保持工作树不变,但将存储库恢复到上次提交之前的状态。令人惊讶的是,我在stackoverflow或google上没有发现任何有用的东西 注意,我不能使用 hg rollback 因为我在最后一次提交后使用HistEdit重写了一些历史记录 添加以澄清: 在一些重定基址和历史编辑之后,我得到了一个复制git reset的正确方法-软头^(撤消当前提交,但保留工作副本中的更改)是: -1仅当要剥离的提交是进入存储库的最后一次提交时

什么是等效的mercurial命令(或工作流)

i、 e.我希望保持工作树不变,但将存储库恢复到上次提交之前的状态。令人惊讶的是,我在stackoverflow或google上没有发现任何有用的东西

注意,我不能使用

hg rollback
因为我在最后一次提交后使用HistEdit重写了一些历史记录

添加以澄清:
在一些重定基址和历史编辑之后,我得到了一个复制
git reset的正确方法-软头^
(撤消当前提交,但保留工作副本中的更改)是:

-1
仅当要剥离的提交是进入存储库的最后一次提交时才起作用
指的是当前签出的提交,它是Mercurial与Git的
头最接近的等价物

请注意,如果
有子体,这些子体也将被剥离。如果您希望保留提交,那么在获得提交ID后,您可以:

hg update .^
hg revert --all -r <commit id>
hg更新^
hg-all-r

这将更新到提交的父级,然后用提交时的版本替换工作副本中的文件。

我认为现在更现代、更简单的方法是
hg uncommit
。请注意,这会留下一个空的提交,如果您希望稍后重用提交消息,这将非常有用。如果没有,请使用
hg uncommit--no keep
不保留空提交

hg uncommit[选项]。。。[文件]

取消部分或全部本地变更集的提交

This command undoes the effect of a local commit, returning the affected
files to their uncommitted state. This means that files modified or
deleted in the changeset will be left unchanged, and so will remain
modified in the working directory.

If no files are specified, the commit will be left empty, unless --no-keep

注意:这需要hg的MQ扩展。Mercurial 2.8和更高版本附带一个专用的。为我工作!我警告说,<代码> Hg条可能会在将来被否决,我应该考虑使用<代码> HG un提交< /C> >或<代码> HG undo-k>代码>。
hg strip --keep -r .
hg update .^
hg revert --all -r <commit id>
This command undoes the effect of a local commit, returning the affected
files to their uncommitted state. This means that files modified or
deleted in the changeset will be left unchanged, and so will remain
modified in the working directory.

If no files are specified, the commit will be left empty, unless --no-keep