Mercurial - 多头 - 我如何“放弃”一个头并把另一个作为提示/默认?

发布于 2024-11-08 16:19:13 字数 533 浏览 0 评论 0原文

我在 Bitbucket 上分叉了别人的存储库并做了一些更改(并将它们推送到我的分叉存储库)。与此同时,原作者做出了实质性的改变(几乎是重写)。

我想将我的存储库更新为与他的完全相同(但我的更改仍然存在于该标签上),这样他就可以轻松地提取我的新更改,而不会影响我之前所做的更改。

我将他的更改拉到我的本地版本中,这给我留下了两个头。我想把他的头作为提示/默认。我试图通过这样做来解决这个问题(基于一些SO答案):

hg update -r [myrev]
hg commit --close-branch
hg update -r [hisrev]

似乎让我处于我想要的状态。我的工作目录看起来像他的。但是,当我尝试 hg Push 时,我被告知这将创建多个远程头,并且我不确定这是否是我想要的(该消息听起来很可怕!)

所以,我这样做正确吗?我应该强行推动吗?这会做我想要的事情吗(例如,保留我的更改的副本,以便我可以访问它们,但通常不会干扰?)。如果是这样,这是实现这一目标的最佳方法吗?

I forked someone elses repository on Bitbucket and made some changes (and pushed them to my forked repo). In the meantime, the original author made substantial changes (pretty much a rewrite).

I want to update my repo to be exactly the same as his (but with my changes still present on that tag) in a way that he can easily pull my new changes without the previous changes I made affecting anything.

I pulled his changes into my local version, which left me with 2 heads. I want to just take his head as the tip/default. I tried to resolve this (based on some SO answers) by doing:

hg update -r [myrev]
hg commit --close-branch
hg update -r [hisrev]

This seemed to put me in a state I wanted. My working directory looks like his. However, when I tryed to hg push I'm told this will create multiple remote heads, and I'm not sure if this is what I want (the message makes it sound scary!)

So, have I done this correctly? Should I force the push? Will this do what I want (eg. keep a copy of my changes so I can get to them, but in a way that generally won't interfere?). If so, was this the best way to achieve this?

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

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

发布评论

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

评论(1

素衣风尘叹 2024-11-15 16:19:13

关闭分支上的头仍然是头,因此如果您想推送这些更改,则需要 --force

另一个选项是将该头合并到您想要成为默认分支的分支中,但不选择任何更改。这可以通过以下方式以非交互方式完成:

hg update [hisrev]
hg --config ui.merge=internal:local merge [myrev]
hg commit

您将只剩下一个头,并且只有他的内容,但您的内容在历史记录中仍然可用。

Heads on a closed branch are still heads, so if you want to push those changes you'll need --force.

The other option, is to merge that head into what you want to be your default branch, but select none of its changes. This can be done non-interactively using:

hg update [hisrev]
hg --config ui.merge=internal:local merge [myrev]
hg commit

You'll be down to one head, and it will have only his content, but yours is still available in the history.

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