mercurial - 在 Mercurial 中移动分支开始

标签 mercurial

我的问题类似于Mercurial move changes to a new branch , 但并不完全相同。

我的一位同事开始研究一项新功能并发布了一些本地提交。然后他注意到“哦,好吧,那应该进入一个命名的分支”,因此创建了一个。问题是,之前的提交应该已经在该分支中了。所以简化的历史现在看起来有点像这样:

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 merge 回“主”< em>default 稍后当我们将 newbranch merge 回 main 时(现在 merge 它们是不希望的,因为它会给 default 带来我们不希望的更改还没有)。

问题是:处理这个问题的最佳方法是什么?

在 5 上执行 --close-branch,在 2 上创建一个新分支并重新应用修订版 3-5?

据我所知,没有什么好的方法可以简单地说“newbranch started at 3 instead of 5”

更新:因为这已经被其他人撤下了,所以我不想对有问题的修订进行 rebase 。强制同事重新创建/切换分支是可以的,因为这只会影响一个人而不是 5 个。

最佳答案

要摆脱额外的默认头部,您可以:

hg update -r 4
hg commit --close-branch -m "Closed extra default head.  The changes from this branch will be merged along with 'newbranch', once it is complete."

当您最终 merge newbranch 时,它将包括修订 3-5 以及您在 5 之上提交的任何其他修订。

唯一的潜在问题是修订版 3-4 不会被标记为命名分支的一部分。如果这对你真的很重要,那么你应该关闭额外的默认头和 newbranch 头,并从一个以修订版 2 为根的新分支重新开始。

关于mercurial - 在 Mercurial 中移动分支开始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7596854/

相关文章:

node.js - 如何在推送后使用 Mercurial 更新和重启 Node 应用程序? (相当于 hg 中的 git post-receive)

svn - 如何实现源控管理互通?

version-control - 防止在 mercurial 中推送目录

git - DVCS repo 设计 - 使用分支或单独的 repo 将开发与稳定分开?

Mercurial 获胜安装 : no ini files

python - 使用 hglib 时如何停止 hg 子进程

visual-studio-2008 - IDE 集成对于 DVCS“真的”有用吗?

mercurial - 构建后提交 : good or bad?

python - PyScripter 是否有 Mercurial 或 Git 版本控制插件?

mercurial - 让 Mercurial 完全忘记文件和历史