在 Mercurial 中创建一个新分支:“中止:推送创建新的远程头”

发布于 2025-01-01 16:30:13 字数 310 浏览 0 评论 0原文

我正在尝试做一些非常简单的事情:创建一个新分支。但我搞砸了。我在哪里犯了错误,该如何解决?

我是 Mercurial 的唯一用户。我已提交修订版 54 并将其推送到远程存储库。我想创建一个基于修订版 53 的分支,因此我将本地副本更新为修订版 53,进行更改并提交(忽略有关“这不是头部”的警告)。然后,当我尝试推送到远程存储库时,它说

abort: push creates new remote head

也许我需要告诉 Mercurial 我想创建一个新分支?如果是这样,如何以及在什么时候?

谢谢!

I am trying to do something very simple: create a new branch. But I messed up. Where did I make the mistake, and how do I fix it?

I am the only user of Mercurial. I had revision 54 committed and pushed to remote repository. I wanted to create a branch based on revision 53, so I updated my local copy to revision 53, made changes, and committed (ignoring the warning about "it's not the head"). Then when I am trying to push to remote repository, it says

abort: push creates new remote head

Maybe I needed to tell Mercurial that I want to create a new branch? If so, how and at what point?

Thanks!

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

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

发布评论

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

评论(3

呆头 2025-01-08 16:30:13

您告诉 Mercurial 它可以继续执行

$ hg push --force

您需要强制它,因为通常不鼓励使用多个(未命名)头。它们的问题是克隆存储库的人不知道要使用哪一个。但由于您是唯一的用户,您可以继续推动。

另一种方法是使用命名分支(带有hg分支),然后您将使用它

$ hg push --new-branch

来允许在远程创建新分支。 命名分支的优点是可以轻松区分两个分支。它们的缺点是它们是永久性的。永久意味着您无法从分支上的变更集中删除分支名称 - 该名称实际上是直接烘焙到变更集中的。

书签提供了一种拥有非永久分支名称的方法,请参阅hg help书签

You tell Mercurial that it can go ahead with

$ hg push --force

You need to force it since multiple (unnamed) heads are normally discouraged. The problem with them is that people that clone the repository wont know which one to use. But since you're the only user you can just go ahead and push.

The alternative is to use a named branch (with hg branch) and then you'll use

$ hg push --new-branch

to allow the creation of a new branch on the remote. Named branches have the advantage that they make it easy to distinguish the two branches. They have the disadvantage that they are permanent. Permanent means that you cannot remove the branch name from the changesets on the branch — the name is literally baked directly into the changeset.

Bookmarks provide a way to have non-permanent branch names, see hg help bookmarks.

人生百味 2025-01-08 16:30:13

出现此错误的另一个原因:默认分支中的中央存储库可能存在一些未合并的更改。

hg up default
hg merge
hg ci -m "Merge"
hg pus

Another reason for this error: probably there are some UNMERGED changes form the central repo in your default branch.

hg up default
hg merge
hg ci -m "Merge"
hg pus
预谋 2025-01-08 16:30:13

我这样做了。使用 TortoiseHg ...这就是我修复它的方法:

在设置中,我启用了 Strip 扩展,然后右键单击我不想要的分支,Modified History - strip。如果您已推送,则需要将其从所有其他存储库中删除,包括拉取您不需要的分支的同事。

另一种方法是将不需要的分支合并到主分支中,但不要从该分支中​​进行任何更改 - 我不确定该机制如何工作。

I did this. Using TortoiseHg ... this is how I fixed it:

In settings, I enabled the Strip extension then right clicked the branch i did not want, Modified History - strip. If you have pushed, then it needs to be stripped from all other repositories, including workmates who have pulled your unwanted branch.

An alternative is to merge the unwanted branch into your main branch, but do not take any of the changes from that branch - I am unsure of how that mechanism works.

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