还有另一种去除多个头的方法吗? [英] Is there another way of removing multiple heads?

查看:70
本文介绍了还有另一种去除多个头的方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说我有这个:

hg init

touch a
hg add a
hg commit -m a

touch b
hg add b
hg commit -m b

hg up -r 0

touch c
hg add c
hg commit -m c

由于最后一次提交,现在我将有多个负责人.例如,如果我想保留最后一个头,即由commit c创建的那个头(有效地丢弃b以及在first之后的所有其他提交),我该怎么做?我用mq的strip命令玩了一点,就可以实现我想要的,但是我想知道是否还有另一种方法.

Now I will have multiple heads, because of the last commit. If, for example I want to keep the last head, the one created by commit c ( effectively discarding b, and all other commits made after the first ) , how could I do it? I played a little with mq's strip command, and I'm able to achieve what I want, but I'd like to know if there's another way.

推荐答案

是的,还有另一种方法.在上面的示例中,hg glog的输出看起来像这样:

Yes, there is another way. From your example above, the output of hg glog looks a bit like this:

@  changeset:   2:925573c7103c
|  tag:         tip
|  parent:      0:4fe26dfe856d
|  user:        Joel B Fant
|  date:        Thu Jul 28 23:20:45 2011 -0400
|  summary:     c
|
| o  changeset:   1:9dc928176506
|/   user:        Joel B Fant
|    date:        Thu Jul 28 23:20:24 2011 -0400
|    summary:     b
|
o  changeset:   0:4fe26dfe856d
   user:        Joel B Fant
   date:        Thu Jul 28 23:20:12 2011 -0400
   summary:     a

如果克隆test指定一个修订版本,则只会克隆该修订版本及其祖先.因此,如果存储库的目录为TwoHeadsMightNotBeBetter,则可以转到其父目录并发出:

If you clone test but specify a revision, it will only clone that revision and its ancestors. So if your repo's directory is TwoHeadsMightNotBeBetter, you can go to its parent directory and issue:

hg clone TwoHeadsMightNotBeBetter OneHeadIsFine -r 925573c7103c

我在其中指定了变更集ID,但是您也可以改用-r 2甚至是-r tip,因为它当前是该回购的提示.现在,当您进入新克隆并执行hg glog时,只有一个脑袋:

I specified changeset id in that, but you could also use -r 2 instead, or even -r tip since it is currently the tip of that repo. Now when you go into the new clone and do hg glog, you have only one head:

@  changeset:   1:925573c7103c
|  tag:         tip
|  user:        Joel B Fant
|  date:        Thu Jul 28 23:20:45 2011 -0400
|  summary:     c
|
o  changeset:   0:4fe26dfe856d
   user:        Joel B Fant
   date:        Thu Jul 28 23:20:12 2011 -0400
   summary:     a


如果您有3个头,但想保持2个头,那就有些不同了.您必须使用-r克隆其中之一,并且还要在hg pull上指定-r才能提取特定分支.


If you had 3 heads and wanted to keep 2, it would be a little different. You'd have to clone one of them with -r and the also specify -r on hg pull to pull specific branches.

这篇关于还有另一种去除多个头的方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆