如何从某些修订/推送中删除 Mercurial 存储库

发布于 2024-09-24 21:42:13 字数 140 浏览 11 评论 0原文

我在最近 4-5 次修订/推送到主存储库时破坏了一些代码。现在我想完全删除这个推送并从那时开始我的存储库的 HEAD 。我怎样才能做到这一点?在 SVN 中,有 dump 命令,它将整个存储库从一个版本复制到另一个版本。 Mercurial 中有替代品还是其他方式?

I have broken some code in my last 4-5 revisions / pushes to main repository. At now I want to completely delete this pushes and start HEAD of my repository from that point. How can I do that? In SVN there is dump command, which copies whole repository from one revision to another. There is some substitute in Mercurial or some other way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

听不够的曲调 2024-10-01 21:42:13

您可以使用转换扩展来执行此操作。
虽然,我真的不明白为什么人们总是想在他们的 VCS 历史记录中隐藏/删除他们犯的错误。只要您在较新的版本中修复它,这并不那么重要......

You can use the convert extension to do that.
Although, I don't really understand why people always want to hide/remove in their VCS history that they made a mistake. It's not that critical as long as you fix it in a newer revision...

゛时过境迁 2024-10-01 21:42:13

Quardas,“完全删除”不属于 Mercurial 的默认词汇。这是一个围绕不可变历史构建的系统。你可以扭转你后悔的事情,但你不能删除它。想象一下一位科学家在他/她的实验室里用笔在日志的编号页上写字——撕下一页被认为是欺诈。保留你的盲目盟友和错误是有价值的,只要你记住不要再犯同样的错误。

考虑使用 hg backout ,它可以轻松自动地添加变更集的反转,从而完全撤消它,但保留变更集及其反转的记录。

如果您确实无法接受这个概念,请尝试研究clone -r。它允许您将存储库克隆到某个点。例如:

hg clone -r -6 myrepo partial-myrepo
mv myrepo myrepo-with-stuff-I-regret
mv partial-myrepo myrepo

这会将您的存储库替换为省略最后五个变更集的新副本。

还有很多其他方法可以使用不属于 Mercurial 默认工具集的工具(例如 histedit、strip、mercurial 队列等扩展)来完成相同的操作,但最好不要删除历史记录并执行此操作如果您这样做,则无需扩展。

Quardas, "completely deleting" isn't part of mercurial's default vocabulary. It's a system built around immutable history. You can reverse something you regret, but you don't delete it. Think of a scientist in his/her lab writing with pen on numbered pages in a logbook -- ripping out a page is considered fraud. There's value in having your blind-allys and mistakes retained if only so you remember not to try that again.

Consider using hg backout which easily and automatically adds the inverse of a changeset thus undoing it completely, but preserving the record of both the changeset and the reversal of it.

If you really can't buy into that concept try looking into clone -r. It lets you clone your repository up to a certain point. For example:

hg clone -r -6 myrepo partial-myrepo
mv myrepo myrepo-with-stuff-I-regret
mv partial-myrepo myrepo

that will replace your repo with a new copy that omits the last five changesets.

Ther are plenty of other ways to do the same thing using tools that aren't part of mercurial's default toolset (extensions such as histedit, strip, mercurial queues, etc.) but you're best off not deleting history at all and doing it w/o extensions if you do.

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