简体   繁体   English

如何在mercurial中清除分支?

[英]How can I purge a branch in mercurial?

I am newbie dealing with mercurial. 我是处理mercurial的新手。 I did some mess trying on branches and now I want to "flat" all branches in just one "default" 我在分支机构上做了一些混乱,现在我想在一个“默认”中“平坦”所有分支

josir@josir-desktop:~/bitbucket/campus$ hg branches
default                       27:f28e8d8773c6
15                            20:6b434f251b7e

branches has already been pushed to remote repo. 分支机构已被推送到远程仓库。

I want to purge all other branches discarding all changes on it. 我想清除所有其他分支机构,丢弃它上面的所有更改。 Reading those tutorial , I could not identify the best option to fix it. 阅读这些教程 ,我找不到解决它的最佳选择。

The easiest thing is to just "close" the unwanted branches and leave them in peace: 最简单的方法就是“关闭”不需要的树枝,让它们平静下来:

hg update -r "branch('15')"
...
hg commit --close-branch 

If you only have push/pull access to the remote repo, there's no way to remove changesets after you've pushed them. 如果您只能对远程仓库进行推/拉访问,则在推送变更集后无法删除变更集。 So close the branch and move on, or discard the bitbucket repo, clean the local one, and start over. 关闭分支并继续前进,或丢弃bitbucket repo,清理本地仓库,然后重新开始。

To clean up your local repo, if you have a big mess the easiest way is to pick a good revision (eg, the tip of default, but you can choose an earlier one) and clone just that and all its ancestors: 要清理你的本地仓库,如果你有一个大混乱,最简单的方法是选择一个好的修订版(例如,默认的提示,但你可以选择一个早期的)并克隆它及其所有的祖先:

hg clone -r <goodrev> messy-repo new-repo

The documentation (which you'd already cited) has a good explanation of this and several other branch-pruning options, but none of them are appropriate after you've pushed to a repository you don't control. 文档 (这你已经引用)有一个很好的解释和其他几个修枝的选择,但你推到你无法控制的仓库后,他们都不是合适的。

对于已被推动的分支,你没有任何自由:只有--close-branch

When I issue hg branches , I got a two column report like the above: 当我发出hg分支时 ,我得到了如上所述的两列报告:

josir@josir-desktop:~/bitbucket/spo$ hg branches
dev                          232:31cf2690dd47 (inativo)

What have I understood for that ? 我对此有何了解?

There are 2 opened branches :( 有2个开放的分支:(

That was my big mistake. 那是我的大错。 There is just ONE branch: dev 只有一个分支:dev

The second column "232:31cf..." is just the last commit of the "dev" branch!!! 第二列“232:31cf ......”只是“开发”分支的最后一次提交!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM