Mercurial - 将两个分支合并为第三个新分支
是否可以将 2 个分支合并到第三个新分支中,而不是将一个分支合并到另一个现有分支中?
Is it possible to, instead of merging one branch into another existing branch, merge 2 branches into a 3rd new branch?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需合并您的 2 个现有分支,并将合并视为第三个新分支的尖端,并将合并分支的前一个头视为您的第一个和第二个分支:
这里书签已用于标记开发中的不同行。因此,如果您想在新的第三个分支上工作,请更新到
masala
,如果您想在第一个分支上工作,请更新到salt
,第二个分支也类似在继续工作和提交之前更新到pepper
。如果您更喜欢使用命名分支(而不是书签),只需在提交修订版 2 和修订版 1 的合并之前发出
hgbranch masala
即可。基本信息是,尽管图表仅包含一个头,您可以自由地将其解释为 3 个不同的开发线。
现在,假设您想继续第二个分支
pepper
的工作:然后您对
salt
事情有了一些想法:现在历史图更清楚地显示您的 3 个分支:
书签和命名分支的替代方法是对各个分支使用不同的克隆。也就是说,您使用未合并的分支克隆您的存储库,并将它们合并到克隆中。哪种方法最好,取决于您的具体工作流程和个人喜好。
Just merge your 2 existing branches and consider the merge as the tip of the 3rd new branch and the previous heads of the merged branches as your 1st and 2nd branch:
Here bookmarks have been used to mark different lines in development. So if you want to work in the new 3rd branch, update to
masala
, if you want to work on your 1st branch, update tosalt
, and similar for the 2nd branch update topepper
before you continue to work and commit.If you prefer working with named branches (instead of bookmarks), just issue a
hg branch masala
before you commit the merge of revision 2 and 1.The basic message is that although the graph only has one head, you are free to interpret it as 3 different lines of development.
Now, let's say you want to continue the work in the 2nd branch,
pepper
:And then you have some ideas for the
salt
thing:Now the history graph shows your 3 branches more clearly:
An alternative to bookmarks and named branches is to use different clones for individual branches. That is you clone your repo with the unmerged branches and merge them in the clone. Which approach is best, depends on your specific workflow and personal preferences.