git – 如何将一个当前分支一次合并到多个后续分支中?

编辑:问题不是将多个分支合并到当前分支.在Stackoverflow上已经回答了几次的东西.

我正在努力找到维护一个伟大但仍在变化的技术(Trailblazer)的教程的最佳方法.

在令人敬畏的Trailblazer book之后,我想为TRB社区提供最简单的可追踪回购.

这是我到目前为止创建的Git-branch结构:

master
  |
  + setup
    |
    + chapter-03-01
      |
      + chapter-03-02
        |
        + chapter-03-03

所以我的问题是……是否有可能对设置进行更改并立即将其合并到所有后续分支,并在第03-01章中进行更改并同时将其合并到连续的分支中?

最佳答案
您可以根据需要合并任意数量的分支

git merge <b1> <b2> <b3>...

有一个很好的工具,你可以在这里阅读:
https://developer.atlassian.com/blog/2015/01/git-merge-distinct-octopus-merge/

从文章中可以看出 – 您可以看到许多分支有多个合并

当与-s标志一起使用时,Git的merge命令支持多个merging strategies.

有两种策略可以同时合并两个以上的分支(章鱼和我们的).

章鱼

This resolves cases with more than two
heads, but refuses to do a complex merge that needs manual resolution.
It is primarily meant to be used for bundling topic branch heads
together. This is the default merge strategy when pulling or merging
more than one branch.

这个默认的合并策略:git merge b1 b2 … bn,是章鱼.

我们的

This option forces conflicting hunks to be auto-resolved cleanly by favoring our version.

Changes from the other tree that do not conflict with our side are reflected to the merge result. For a binary file, the entire contents are taken from our side.

This should not be confused with the ours merge strategy, which does not even look at what the other tree contains at all. It discards everything the other tree did, declaring our history contains all that happened in it.

enter image description here

转载注明原文:git – 如何将一个当前分支一次合并到多个后续分支中? - 代码日志