Mercurial:如何推送到默认分支?

发布于 2024-10-04 22:11:27 字数 710 浏览 3 评论 0原文

我正在使用 Mercurial,并且是个新手。我刚刚成功提交了对我的存储库的更改,然后成功运行 hg pullhg update - 没有合并,也没有出现冲突。

然后我尝试推送到远程存储库,并得到了可怕的结果: abort: push Creates new Remote Heads!

hg glog 显示以下内容:

@  changeset:   576:c4c58970f141
|  tag:         tip
|  user:        me
|  parent:      566:70e287df5439
|
| o  changeset:   575:7ae70ddd2b6e
| |  branch:      mongo
| |
| o  changeset:   574:904da90475ef
| |  branch:      mongo
| |
| o  changeset:   567:cad7a006965b
|/   branch:      mongo
|
o  changeset:   566:70e287df5439
|  user:        me
|  

看起来有人创建了一个新的 远程头存储库中的分支,这很好:我只想将更改推送到默认分支,但我不知道如何操作。

我如何推送变更集 576?我需要指定它是默认分支吗?

I'm using Mercurial and am a bit of a newbie. I just committed a change to my repo successfully, then ran hg pull and hg update successfully - no merges and no conflicts showed up.

Then I tried to push to the remote repo, and got the dreaded: abort: push creates new remote heads!

hg glog shows the following:

@  changeset:   576:c4c58970f141
|  tag:         tip
|  user:        me
|  parent:      566:70e287df5439
|
| o  changeset:   575:7ae70ddd2b6e
| |  branch:      mongo
| |
| o  changeset:   574:904da90475ef
| |  branch:      mongo
| |
| o  changeset:   567:cad7a006965b
|/   branch:      mongo
|
o  changeset:   566:70e287df5439
|  user:        me
|  

Looks like someone has created a new branch in the repo, which is fine: I just want to push my changes to the default branch, but I don't know how.

How can I push changeset 576? Do I need to specify that it's to branch default?

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

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

发布评论

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

评论(3

再浓的妆也掩不了殇 2024-10-11 22:11:27

Mercurial 的 push 命令具有 -r 选项,用于限制推送更改至给定修订版:

如果使用 -r/--rev,则指定的修订版及其所有祖先都将被
推送到远程存储库。

这意味着您还限制了要推送的分支。要将所有更改推送到默认分支的顶端,您可以运行:

$ hg push -r default

这将忽略您的 mongo 分支。除了分支名称之外,您还可以使用特定修订版:

$ hg push -r 576

显然,只要修订版 576 是默认分支的尖端,这两个命令就具有相同的效果。

顺便说一句,有一个通常很方便的快捷方式可以仅推送当前签出的工作副本的父版本,使用句点作为版本说明符:

$ hg push -r .

Mercurial's push command has the -r option to limit the push to changes up to a given revision:

If -r/--rev is used, the specified revision and all its ancestors will be
pushed to the remote repository.

This implicates that you also limit the branch you're going to push. To push all changes up to the tip of the default branch, you could run:

$ hg push -r default

This will ignore your mongo branch. Instead of branch names, you can also use specific revisions:

$ hg push -r 576

Obviously, as long as revision 576 is the tip of the default branch, both commands have the same effect.

On a side note, there is an often handy shortcut to push only the parent revision of the currently checked out working copy, using a period as the revision specifier:

$ hg push -r .
無心 2024-10-11 22:11:27

还发生了其他事情,因为像 mongo 这样的远程分支不会导致多头中止,只有同一分支上的多个头才会导致。 [更新:实际上,您确实会得到远程分支中止,类似于远程头中止,除非您像我一样在TortoiseHg的同步菜单中选中了推送新分支 ]

无论原因如何,正确的程序是提交到本地存储库(您已经完成了),然后远程更改,将它们与您的合并提交结果,最后推送合并的更改到存储库。

有一个名为 fetch 的扩展,它有助于将此过程合并为一个步骤。您可以在此处了解更多信息。

不要只是强制推送到远程存储库!这只是避免合并的责任,甚至可能会破坏一些东西,例如依赖于在无分支行中进行所有更改的构建系统。至少你会让与你一起工作的人感到困惑或恼怒。除非那是您的意图,在这种情况下,请全速前进。 :)

在开始之前,您确实需要阅读一些有关协作的基础知识。从此处开始。

Something else is going on because a remote branch like mongo doesn't cause a multiple head abort, only multiple heads on the same branch do. [Update: Actually, you do get a remote branch abort, analogous to a remote head abort, unless you have Push new branch checked in the Synchronize menu of your TortoiseHg as I did.]

No matter the cause, the proper procedure is to commit to your local repo (which you've done), then pull the remote changes, merge them with yours, commit the result and, finally, push the merged changes to the repo.

There is an extension called fetch which helps consolidate this process into a single step. You can learn more about it here.

Don't just force the push to the remote repo! This is just avoiding responsibility for the merge and may even break things, such as a build system which relies on having all changes in an unbranched line. At the least you will confuse or irritate those you are working with. Unless that is your intention, in which case, full steam ahead. :)

You really need to read some of the basics about collaboration before you start doing it. Start here.

葮薆情 2024-10-11 22:11:27

请参阅最近关于此的讨论

Mercurial 总是会抱怨在远程创建新头。创建新头时必须使用 --force 或 --new-branch。

[编辑:]

这专门是为了让用户意识到他正在远程存储库中引入多个头。通常的做法是不使用push命令来创建头。如果您想在远程存储库(通常是中央存储库)上创建多个头。

正如 Binary Phile 所说,这会导致向上推动合并。这不好。

See a very recent discussion on this

Mercurial will always complain about creating new heads on the remote. You must use either --force or --new-branch when creating a new head.

[Edit:]

This is specifically to make the user aware that he is introducing multiple head in remote repository. Normal practice is not to create heads by using push command. If you want to create multiple heads on the remote repo (Which usually is central repo).

As Binary Phile, says perfectly, this causes pushing the merge upwards. Which is not good.

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