开发者

Mercurial - Multiple heads - how do I "abandon" one head and take the other as tip/default?

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? Shoul开发者_StackOverflow社区d 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜