如何恢复 Mercurial hg 拉动?

发布于 2024-10-14 04:10:40 字数 250 浏览 3 评论 0原文

如果您执行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 技术交流群。

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

发布评论

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

评论(5

柠檬心 2024-10-21 04:10:41

好吧,你不能回滚,因为你已经完成了提交。您可以做的是使用 'hg strip',它是 mq 的一部分(2.8 strip 之后是它自己的扩展),或者使用 mq 删除更改​​。不管怎样,我建议你在另一个克隆上做所有事情,以防万一。

要进行剥离,请更新到要保留的修订版,然后

hg strip <REV>

其中 是您要删除的第一个修订版。它将删除该一个和所有后代(包括您的合并提交)。

或者,您可以

hg qnew (if you don't already have a patch queue)
hg qimport <REV>

将单个修订版导入补丁队列。然后,您可以添加更多内容,然后使用 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

hg strip <REV>

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

hg qnew (if you don't already have a patch queue)
hg qimport <REV>

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.

童话里做英雄 2024-10-21 04:10:41

hg --rollback 可用于撤消最后一个事务,因此只要您的 hg pull 仍然是最近的事务,那么您就可以使用它。但应谨慎使用此命令。请参阅此处了解更多详细信息。

hg --rollback can be used to undo the last transaction so as long as your hg 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.

勿忘初心 2024-10-21 04:10:41

您可以:

hg update -C <version>

查看 Mercurial 常见问题解答

you can:

hg update -C <version>

see the mercurial FAQ.

坚持沉默 2024-10-21 04:10:41

如果你想从历史记录中删除所有拉动痕迹,那么你需要使用 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 or hg revert -r which will stay on the same branch but create a new uncommited change undoing everything.

自控 2024-10-21 04:10:40

hg strip 将从存储库中删除修订。像所有强大的命令一样,它很危险,所以要小心。

https://www.mercurial-scm.org/wiki/StripExtension

另请参阅:

https://www.mercurial-scm.org/wiki/EditingHistory

如果您立即(或很快)发现错误,则只需使用hg strip REV即可回滚最新(一个或多个)更改。 ...

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

If you catch your mistake immediately (or reasonably soon), you can just use hg strip REV to roll back the latest (one or more) changes. ...

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