Mercurial - 将两个分支合并为第三个新分支

发布于 2024-10-25 06:18:35 字数 49 浏览 3 评论 0原文

是否可以将 2 个分支合并到第三个新分支中,而不是将一个分支合并到另一个现有分支中?

Is it possible to, instead of merging one branch into another existing branch, merge 2 branches into a 3rd new branch?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

背叛残局 2024-11-01 06:18:35

只需合并您的 2 个现有分支,并将合并视为第三个新分支的尖端,并将合并分支的前一个头视为您的第一个和第二个分支:

o    changeset:   3:92692c4a6b12
|\   bookmark:    masala
| |  summary:     merge salt and pepper
| |
| o  changeset:   2:a5f955adf03d
| |  bookmark:    pepper
| |  summary:     add some pepper
| |
o |  changeset:   1:2b56f2dc115f
|/   bookmark:    salt
|    summary:     add some salt
|
o  changeset:   0:e992ce7dd508
   summary:     initial

这里书签已用于标记开发中的不同行。因此,如果您想在新的第三个分支上工作,请更新到 masala,如果您想在第一个分支上工作,请更新到 salt,第二个分支也类似在继续工作和提交之前更新到 pepper

如果您更喜欢使用命名分支(而不是书签),只需在提交修订版 2 和修订版 1 的合并之前发出 hgbranch masala 即可。

基本信息是,尽管图表仅包含一个头,可以自由地将其解释为 3 个不同的开发线。

现在,假设您想继续第二个分支 pepper 的工作:

$ hg up pepper
... hack ...
$ hg ci -m "need more pepper"

然后您对 salt 事情有了一些想法:

$ hg up salt
... hack ...
$ hg ci -m "less salt please"

现在历史图更清楚地显示您的 3 个分支:

o  changeset:   5:d1f8eb72119a
|  bookmark:    salt
|  summary:     less salt please
|
| o  changeset:   4:acc9b01f584f
| |  bookmark:    pepper
| |  summary:     need more pepper
| |
+---o  changeset:   3:92692c4a6b12
| |/   bookmark:    masala
| |    summary:     merge salt and pepper
| |
| o  changeset:   2:a5f955adf03d
| |  summary:     add some pepper
| |
o |  changeset:   1:2b56f2dc115f
|/   summary:     add some salt
|
o  changeset:   0:e992ce7dd508
   summary:     initial

书签和命名分支的替代方法是对各个分支使用不同的克隆。也就是说,您使用未合并的分支克隆您的存储库,并将它们合并到克隆中。哪种方法最好,取决于您的具体工作流程和个人喜好。

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:

o    changeset:   3:92692c4a6b12
|\   bookmark:    masala
| |  summary:     merge salt and pepper
| |
| o  changeset:   2:a5f955adf03d
| |  bookmark:    pepper
| |  summary:     add some pepper
| |
o |  changeset:   1:2b56f2dc115f
|/   bookmark:    salt
|    summary:     add some salt
|
o  changeset:   0:e992ce7dd508
   summary:     initial

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 to salt, and similar for the 2nd branch update to pepper 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:

$ hg up pepper
... hack ...
$ hg ci -m "need more pepper"

And then you have some ideas for the salt thing:

$ hg up salt
... hack ...
$ hg ci -m "less salt please"

Now the history graph shows your 3 branches more clearly:

o  changeset:   5:d1f8eb72119a
|  bookmark:    salt
|  summary:     less salt please
|
| o  changeset:   4:acc9b01f584f
| |  bookmark:    pepper
| |  summary:     need more pepper
| |
+---o  changeset:   3:92692c4a6b12
| |/   bookmark:    masala
| |    summary:     merge salt and pepper
| |
| o  changeset:   2:a5f955adf03d
| |  summary:     add some pepper
| |
o |  changeset:   1:2b56f2dc115f
|/   summary:     add some salt
|
o  changeset:   0:e992ce7dd508
   summary:     initial

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文