gpt4 book ai didi

git - 如何一次将一个当前分支 merge 到多个后续分支?

转载 作者:太空狗 更新时间:2023-10-29 13:15:11 24 4
gpt4 key购买 nike

编辑:问题不是将多个分支 merge 到当前分支。在 Stackoverflow 上已经回答了几次的问题。

我正在努力寻找最好的方法来维护一个伟大但仍在变化的技术的教程 (Trailblazer)。

跟随真棒Trailblazer book ,我想为 TRB 社区提供最简单的可跟踪 repo 。

这是我目前创建的 Git 分支结构:

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

所以我的问题是......是否可以对 setup 进行更改并将其立即 merge 到所有后续分支,例如对 chapter-03-01 进行更改并将其 merge 到后续分支也是一次吗?

最佳答案

你可以 merge 任意数量的分支

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

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

取自文章——你可以看到有很多分支的多重 merge


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

有两种策略可以同时 merge 两个以上的分支(octopus 和我们的)。

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.

默认的 merge 策略:git merge b1 b2 ... bn,是octopus

我们的

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 - 如何一次将一个当前分支 merge 到多个后续分支?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34556494/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com