如何恢复 Mercurial hg 拉动?
如果您执行hg pull
,然后执行hg update
(或hg merge
),是否有办法取消此操作?即:将存储库恢复到执行 hg pull
之前的状态?
我相信您可以执行hg update -r n
,其中您可以将拉取之前的变更集指定为n
。虽然我猜测这仍然会将变更集保留在您的存储库中,但这并不是我们真正想要的。 ??
If you do an hg pull
and then an hg update
(or an hg merge
), is there a way to back this out? Ie: revert your repository to the state prior to doing the hg pull
?
I believe you can do hg update -r n
where you would specify the changeset prior to the pull as n
. Though I'm guessing this will still leave the changesets in your repository but this isn't really what we want. ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
好吧,你不能回滚,因为你已经完成了提交。您可以做的是使用 'hg strip',它是 mq 的一部分(2.8 strip 之后是它自己的扩展),或者使用 mq 删除更改。不管怎样,我建议你在另一个克隆上做所有事情,以防万一。
要进行剥离,请更新到要保留的修订版,然后
其中
是您要删除的第一个修订版。它将删除该一个和所有后代(包括您的合并提交)。或者,您可以
将单个修订版导入补丁队列。然后,您可以添加更多内容,然后使用 mq 命令来编辑、重新排列、删除或对这些修订执行任何您想要执行的操作。
qdel
删除当前补丁。编辑:显然,您需要为这两个版本启用 MQ 扩展,除非您使用的是 2.8 或更高版本。在这种情况下,strip 位于 strip 扩展中,mq 位于 mq 扩展中。两者都附带标准安装。
Ok, you can't rollback because you've done a commit. What you can do is use 'hg strip' which is part of mq (after 2.8 strip is in it's own extension), or use mq to remove the changes. Either way I suggest you do everything on another clone, just in case.
To do strip, update to a revision that you want to keep, and then
where
<REV>
is the first revision you want to remove. It will remove that one and all decendents (including your merge commit).Alternatively you can
which will import a single revision into the patch queue. You can then add more, and then use the mq commands to edit, rearrange, delete, or whatever you want to do with those revisions.
qdel
deletes the current patch.Edit: Obviously, you'll need to enable the MQ extension for both of these, unless you're using 2.8 or later. In that case strip is in the strip extension, and mq in the mq extension. Both are shipped with the standard installation.
hg --rollback
可用于撤消最后一个事务,因此只要您的hg pull
仍然是最近的事务,那么您就可以使用它。但应谨慎使用此命令。请参阅此处了解更多详细信息。hg --rollback
can be used to undo the last transaction so as long as yourhg pull
is still the most recent transaction then you can use that. This command should be used with care though. See here for some more details.您可以:
查看 Mercurial 常见问题解答。
you can:
see the mercurial FAQ.
如果你想从历史记录中删除所有拉动痕迹,那么你需要使用 Bert F 建议的扩展(mercurial 的哲学是永远不会改变历史记录),
如果你不介意历史记录包含你的错误,你有两个略有不同的选择< code>hg update -C -r 这将在您指定的版本上创建一个新分支,或者
hg revert -r
它将保留在同一分支上,但创建一个新的未提交的更改,撤消所有内容。If you want to remove all traces of the pull form your history then you need to use an extension as Bert F suggests (the philosophy in mercurial is to never change history)
if you dont mind history containing your mistake you have two slightly different options
hg update -C -r
which will create a new branch at the version you specify orhg revert -r
which will stay on the same branch but create a new uncommited change undoing everything.hg strip
将从存储库中删除修订。像所有强大的命令一样,它很危险,所以要小心。https://www.mercurial-scm.org/wiki/StripExtension
另请参阅:
https://www.mercurial-scm.org/wiki/EditingHistory
hg strip
will remove revisions from a repository. Like all powerful commands, its dangerous, so be careful.https://www.mercurial-scm.org/wiki/StripExtension
Also see:
https://www.mercurial-scm.org/wiki/EditingHistory