简体   繁体   English

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

[英]How to merge one current branch into multiple following branches at once?

Edit: Question is NOT merging multiple branches into current branch.编辑:问题不是将多个分支合并到当前分支。 Something that was already answered a couple times on Stackoverflow.在 Stackoverflow 上已经回答了几次的问题。

I'm trying to find the best way to maintain a tutorial for a great but still changing technology ( Trailblazer ).我正试图找到最好的方法来维护一个伟大但仍在变化的技术 ( Trailblazer ) 的教程。

Following the awesome Trailblazer book , I would like to offer the TRB community the easiest followable repo.在很棒的Trailblazer 书之后,我想为 TRB 社区提供最简单的可遵循的回购协议。

This is the Git-branch structure I created so far:这是我到目前为止创建的Git 分支结构

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

So my question is… Is it possible to make changes on setup and merge it to all following branches at once, and make changes for example on chapter-03-01 and merge it to successive branches at once as well?所以我的问题是......是否可以对setup进行更改并将其立即合并到所有后续分支,并在 chapter-03-01 上进行更改并立即将其合并到后续分支?

I am not 100% sure, but I think the strategy that you're looking to apply would be an " Octopus Merge " 我不确定100%,但是我认为您要采用的策略是“ 八达通合并

From the git documentation : git文档

Octopus 章鱼

" 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 ." 这解决了具有两个以上头的情况,但是拒绝执行需要手动解决的复杂合并。它主要用于将主题分支头捆绑在一起。这是拉或合并多个分支时的默认合并策略 ”。

You can merge as many branches as you wish您可以根据需要合并任意数量的分支

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

There is a nice tool which you can read about here:有一个很好的工具,您可以在这里阅读:
https://developer.atlassian.com/blog/2015/01/git-merge-distinct-octopus-merge/ https://developer.atlassian.com/blog/2015/01/git-merge-distinct-octopus-merge/

Taken form the article - you can see that there is a multiple merge of many branches从文章中获取 - 你可以看到有许多分支的多重合并


Git's merge command supports multiple merging strategies when used with -s flag.当与-s标志一起使用时,Git 的merge命令支持多种合并策略

There are two strategies that can merge more than two branches at a time (octopus & ours).有两种策略可以一次合并两个以上的分支(章鱼和我们的)。

octopus章鱼

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.这是拉取或合并多个分支时的默认合并策略。

The default merge strategy for this: git merge b1 b2... bn , is octopus .这个的默认合并策略: git merge b1 b2... bnoctopus

ours我们的

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.它丢弃了另一棵树所做的一切,宣布我们的历史包含其中发生的所有事情。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM