如何在Mercurial中通过克隆修剪分支? [英] How can I prune branches with cloning in Mercurial?

查看:81
本文介绍了如何在Mercurial中通过克隆修剪分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个商务项目,并且我这样做:

Let's say I have a mercurial project and I do this:

hg branch whatever
touch newfile
hg add newfile
hg commit -m "added newfile" --close-branch
hg up -C default
hg merge whatever
hg push
abort: push creates new remote branch 'whatever'!
(did you forget to merge? use push -f to force)

如何删除该分支,以使hg branches -c不在该分支显示?令人沮丧的是,这不允许我使用bitbucket.我阅读了文档,但是前两点我可能没有正确遵循(因为我一直即使我合并了),也会收到错误消息.第三点,关于通过clone删除,我不知道该怎么做,因为我也总是在回购协议中加入功能分支.

How can I remove the branch so that hg branches -c will not show it there? It's kind of frustrating that this is not allowing me to push to bitbucket. I read the Documentation, but the first two points I'm probably not following correctly ( since I keep getting the error, even though I merged ). The third point, about removing via clone I don't understand how to do, since I always end up with the feature branch in my repo too.

推荐答案

首先,您没有没有删除该分支.

Well, first of all, you don't have to remove that branch.

警告仅仅是,警告您应该仔细检查您确实在做正确的事情,并且不要将分支推入不属于该分支的地方.

The warning is just that, a warning that you should double-check that you're indeed doing the right thing, and not pushing a branch somewhere it doesn't belong.

但是,如果您要保留分支,请按照警告中的说明操作,并使用-f选项进行推送:

However, if you want to keep the branch, just do what the warning says, push with the -f option:

hg push -f

另一方面,现在,如果您要删除它,可以按照以下方法进行操作:

Now, on the other hand, if you do want to remove it, here's the ways you can do it:

如果启用了"mq"扩展名,则可以删除更改集:

If you have the "mq" extension enabled, you can strip off the changeset:

 hg strip REV

此版本从存储库中删除 REV修订版及其后的所有内容.

This removes the revision REV, and everything that follows from it, from the repository.

仅在不确定效果或不确定是否要这样做时,才应在克隆中执行此操作

另一种方法是将不想推送的变更集弹出队列.我不知道这是否适用于整个分支,我也不知道确切的命令.

Another way is to pop the changesets you don't want to push into a queue. I don't know if this will work with a whole branch, neither do I know the exact command for this.

基本上,您可以克隆想要保留的内容

Basically you clone what you want to keep

hg clone --branch default original newclone

这将从original克隆到newclone,并且仅克隆默认分支.如果您要克隆的分支多于默认分支,则可以对要克隆的每个分支重复--branch NAME选项.

This will clone from original to newclone and only clone the default branch. If you want to clone more than the default branch, you can repeat the --branch NAME option for each branch you want to clone.

同样,在将任何内容推送到中央存储库之前,请确保您尝试使用新鲜的克隆并验证所需的内容.

Again, make sure you experiment with fresh clones and verify that you get what you want before pushing anything to the central repository.

这篇关于如何在Mercurial中通过克隆修剪分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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