【问题标题】:Reusing a branch that has been merged into default重用已合并到默认的分支
【发布时间】:2014-01-15 21:46:51
【问题描述】:
使用 Mercurial 时,假设您使用的是“默认”分支。您通过创建新分支并将它们合并回“默认”来工作(当您在该新分支上的工作完成时)。
在将新分支(称为“myBranch”)合并回“默认”后,您实际上决定需要在“myBranch”上工作。 'myBranch' 此后一直没有关闭。在“myBranch”上工作的最佳方式是什么?
【问题讨论】:
标签:
version-control
mercurial
merge
tortoisehg
【解决方案1】:
- 合并分支(在 Mercurial 中)并不意味着它会关闭|消失。使用过的牧场永远是 Mercurial 变更集的永久部分
- 合并不会关闭分支,只是删除合并分支的 HEAD
- 因为 Mercurial 的历史是 DAG,所以您始终可以返回 (
hg up CS-ID) 到其中的任何条目(变更集)并从此时开始工作,在提交时添加新的子变更集
- 对于命名分支,branchname 是该分支最新(拓扑)变更集 HEAD 的 CS-ID
对于 LTB “清理”,我在每次将其合并到默认分支后使用 hg up Cleanup
【解决方案2】:
没有额外的事情可做。如果您想从 myBranch 中的最后一次提交继续,请执行以下操作:
hg checkout myBranch # checks out last commit in myBranch
...hack...
hg commit # creates a new commit on myBranch
相反,如果您想使用deafult(罕见)上的任何内容重新打开 myBranch,您可以这样做:
hg checkout default
hg branch --force myBranch # says "next commit should be on branch myBranch and I don't care if there already was one"
...hack...
hg commit
你可能想要第一个。