如何从特定 Mercurial 克隆中删除某些变更集?
我有一个版本为 2048 的中央存储库的克隆。我想删除本地存储库上的最后 10 个变更集,就像我回到了两周前一样。我想我可以删除本地存储库并执行 "hg clone -rev 2038"
但这会很长(克隆存储库需要几分钟)。有没有办法“拉动”一些变更集?
注意:
- 我并不是想撤销更改集。我最终将再次从中央存储库中提取这些变更集。
- 我并不是试图将工作目录更新为早期版本;我真的很想影响存储库。
- 我当前的存储库和工作目录中没有任何传出的更改集或待处理的修改。
I have a clone of a central repo at rev 2048. I want to remove the last 10 changesets on my local repo as if I was back in time two weeks ago. I suppose I could delete my local repo and do "hg clone -rev 2038"
but that would be long (cloning the repo takes several minutes). Is there a way to just "unpull" some changesets?
Notes:
- I'm not trying to backout the changesets. I'll eventually pull those changesets again from the central repo.
- I'm not trying to update the working directory to an earlier version; I really want to affect the repository.
- I don't have any outgoing changesets or pending modifications in my current repo and working directory.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 strip 命令:
此命令由 StripExtension 提供。它作为 Mercurial 2.8 及更高版本的一部分进行分发,但您需要首先通过将以下行添加到 .hgrc 或 Mercurial.ini 来启用它:
在 Mercurial 2.8 之前,它是 MqExtension。
为了防止您意外破坏历史记录,该命令将在
.hg/strip-backup/
中生成一个备份包,您可以根据需要再次hg unbundle
。Use the strip command:
This command is provided by the StripExtension. It is distributed as part of Mercurial 2.8 and later, but you do need to enable it first by adding the following lines to your .hgrc or Mercurial.ini:
Before Mercurial 2.8, it was part of the MqExtension.
To prevent you from accidentally destroying history, the command will generate a backup bundle in
.hg/strip-backup/
which you canhg unbundle
again if desired.克隆本地存储库应该很快。我认为“几分钟”是指远程仓库?
您可以使用
hg clone; <新仓库> -r
仅克隆到某个版本。Cloning your local repo should be fast. I assume "several minutes" refers to a remote repo?
You can use
hg clone <local repo> <new repo> -r <revision>
to only clone up to a certain revision.要删除已提交并推送的变更集,请使用:
要删除已提交但未推送的变更集,请使用:
To remove a changeset that was already committed and pushed use :
To remove a changeset that was committed but not pushed use :
对于 Mercurial 2.8 之前的版本,Strip 是 MqExtension 的一部分。
如果您需要启用旧的 MQ 扩展,
您可以通过添加以下内容来做到这一点:
到您的 ~/.hgrc (或mercurial.ini)文件中。
Strip 信息曾经位于此处,但现在可以此处。
For versions previous to Mercurial 2.8, the Strip was part of the MqExtension.
In case you need to Enable the old MQ Extensions,
you can do it by adding this:
to your ~/.hgrc (or mercurial.ini) file.
The Strip information used to be here but now it can be found here.