如何只推送到 Hg 中的一个分支?

发布于 2024-10-15 10:07:00 字数 409 浏览 1 评论 0原文

我有一个 Hg 存储库,其中有 3 个分支,但其中两个处于非活动状态(因为我已经将它们合并到我的默认分支中)。 hg Heads 显示 3 个头,每个分支一个,尽管 hg Branches 显示其中 2 个分支为“非活动”。

当我尝试将默认分支(使用 hg push --branch default http://...)推送到另一个存储库时,合并将中止,并显示消息“abort:push 创建新的远程分支” :!”

从 Hg Push 手册页来看,“默认情况下,推送不允许在目的地创建新的头,因为多个头会导致不清楚使用哪个头。在这种情况下,建议在推送之前拉取并合并。”

我已经这样做了,但我仍然无法在不中止的情况下推送 --branch default 。

任何帮助表示赞赏。谢谢!

I have a Hg repo with 3 branches in it, but two of them are inactive (since I have already merged them into my default branch). hg heads shows 3 heads, one for each branch, even though hg branches shows 2 of those branches as 'inactive'.

When I try to push my default branch (using hg push --branch default http://...) to another repo, the merge is aborted with the message "abort: push creates new remote branches: !"

From the Hg push man pages, "By default, push will not allow creation of new heads at the destination, since multiple heads would make it unclear which head to use. In this situation, it is recommended to pull and merge before pushing."

I've already done that, but I still cant push --branch default without it getting aborted.

Any help is appreciated. Thanks!

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

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

发布评论

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

评论(3

陪你到最终 2024-10-22 10:07:00

如果 default 上的变更集在其他分支上有祖先变更集,您也必须推送这些变更集。如果某个变更集的所有变更集都不存在,则变更集不可能存在于存储库中。

所以尝试一下:

hg push --branch default --new-branch

“是的,我知道这个推送发送了远程存储库之前从未见过的分支名称”(它还需要 Mercurial 1.6 或更高版本的 IIRC)>

另外,您可以将那些不活动的头设为封闭头:

hg update thebranch
hg commit --close-branch -m 'closing'

因为“命名分支是永远的”,许多人选择将它们保留为长期存在的概念,如“稳定”和“实验”,并使用书签、匿名分支或克隆来表示功能、发布和其他暂时性的东西。有关其他选项的指南,请参阅此内容。

If changesets on default have ancestor changesets on other branchs you have to push those changesets too. It's not possible for a changeset to exist in a repo without all of its changesets also existing.

So try:

hg push --branch default --new-branch

which says "yeah, I know this push sends across a branch name that the remote repo hasn't previously seen before" (it also requires Mercurial 1.6 or later IIRC)>

Also, you can take those inactive heads and make them closed heads with:

hg update thebranch
hg commit --close-branch -m 'closing'

Because "named branches are forever" many folks choose to reserve them for long lived concepts like "stable" and "experimental" and use bookmarks, anonymous branches, or clones for features, releases, and other transitory things. See this for a guide on those other options.

吾家有女初长成 2024-10-22 10:07:00

要推送单个分支,您只需使用 -b

hg push -b myBranch

对于特定问题,您可能需要研究关闭分支。我知道 SourceTree 提供了它,但我不确定具体细节

To push a single branch you just use -b

hg push -b myBranch

as for the specific issue, you may want to look into closing branches. I know SourceTree offers it, but I'm not sure on the specifics

够钟 2024-10-22 10:07:00

你可以强制它!

方法如下:

1. Pull from your repository
2. hg push --rev nnn -f (replace nnn with your Rev # of your working branch)
3. do NOT force before PULLing. if you do things will get out sync and you are screwed

如果您使用的是 RhodeCode 之类的东西,那么在强制执行后检查一下,您将看到最新的分支就在那里。

不过我认为稍后 Mercurial 会要求您再次推送另一个分支,即使您关闭它,Mercurial 也会尝试在服务器上创建该分支。

我也是 Git 用户,也遇到了同样的情况,因为客户正在使用 Mercurial,但我想使用 Git 工作流程风格。

我认为这是可行的,但我还没有100%弄清楚。

You can FORCE it!

Here is how:

1. Pull from your repository
2. hg push --rev nnn -f (replace nnn with your Rev # of your working branch)
3. do NOT force before PULLing. if you do things will get out sync and you are screwed

If you are using something like RhodeCode then check it out after forcing it and you will see that your latest branch is there.

However I think that later on Mercurial is going to ask you to push the other branch again, even if you close it, Mercurial will try to create that branch on a server.

I'm a Git user also and ran into the same situation because a customer is using Mercurial but I would like to use Git workflow style.

I think it is doable but I have not figured out 100% yet.

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