在 Mercurial 中移动分支起点
我的问题类似于 Mercurial 将更改移动到新分支,但是并不完全相同。
我的一位同事开始开发一项新功能并发布了一些本地提交。然后他注意到“哦,好吧,那应该进入一个命名分支”,因此创建了一个。问题是,之前的提交应该已经在该分支中了。所以简化的历史现在看起来有点像这样:
O 7: default
|
O 6: default
|
| O 5: newbranch
| |
| O 4: default
| |
| O 3: default
| /
O 2: default
|
O 1: default
所以 default 现在有两个开放头:7 和 4。我想去掉开放头 4,但当然仍然有 3 和 4稍后当我们将newbranch合并回main时,合并回“main”default(现在合并它们是不受欢迎的,因为它会将更改带入default > 我们不想要那里 然而)。
问题是:处理这个问题的最佳方法是什么?
在 5 上执行 --close-branch
,在 2 上创建一个新分支并重新应用修订版 3-5 ?
据我所知,没有什么好方法可以简单地说“newbranch 从 3 而不是 5 开始”。
更新:由于这已经被其他人拉走了,我不想重新调整相关修订。强迫同事重新创建/切换分支是可以的,因为这只会影响 1 个人而不是 5 个人。
My problem is similar to Mercurial move changes to a new branch, but is not exactly the same.
A colleague of mine started working on a new feature and issued a few local commits. Then he noticed "Oh well, that should go into a named branch" and thus created one. The problem is, the commits before should have been in that branch already. So the simplified history now looks a little like this:
O 7: default
|
O 6: default
|
| O 5: newbranch
| |
| O 4: default
| |
| O 3: default
| /
O 2: default
|
O 1: default
So default now has two open heads: 7 and 4. I'd like to get rid of the open head 4 but of course still have 3 and 4 merged back into the "main" default later on when we merge newbranch back into main (merging them now is undesired as it would bring changes into default that we don't want there yet).
The question is: what's the best way to handle this ?
Do a --close-branch
on 5, create a new branch off 2 and re-apply revisions 3-5 ?
As far as I've understood there's no good way to simply say "newbranch started at 3 instead of 5".
Update: Since this is has already been pulled by others I don't want to rebase the revisions in question. Forcing the colleague to recreate/switch branches would be OK since that would affect only one person instead of 5.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要摆脱额外的默认头,您可以:
当您最终合并
newbranch
时,它将包括修订版 3-5 以及您在 5 之上提交的任何其他修订版。唯一的潜在问题是修订版 3-4 将不会被标记为指定分支的一部分。如果这对您来说真的很重要,那么您应该关闭额外的默认头和 newbranch 头,并从以修订版 2 为根的新分支重新开始。
To get rid of the extra default head, you could:
When you eventually merge
newbranch
, it will include revisions 3-5 plus any others that you commit on top of 5.The only potential problem with this is that revisions 3-4 will not be labeled as part of the named branch. If this is really important for you, then you should close both the extra default head and the
newbranch
head and start over with a new branch rooted at revision 2.