首页 > 解决方案 > Approach to use git with two masters

问题描述

We have two customers (and counting) which share like 80% code of a project, the main differences are like images, config files and some HTML. There is nothing like a master, because without the individually data the project could not run.

What would be the best practice to handle this scenario with git? Is it possible to use git flow somehow?

Currently we just have 4 branches:

customer1_dev -> customer1_master
customer2_dev -> customer2_master

We are Cherry-picking most of the commits between those.

标签: git

解决方案


在这种情况下使用 Git 管理代码库时的主要选择是从公共代码库分支,然后为每个客户维护单独的分支(并将对这些客户分支的提交限制为他们的特定内容)。所有共同的发展都应该发生在主线分支中。

然后,当您准备好为特定客户构建发布候选版本时,切换到他们branch并执行以下操作:git merge master进入该客户的分支。这会将所有更改从主线引入您的客户特定分支。

你可以做一个rebase而不是合并。但这不太有利,因为如果在主线分支之外的客户分支中弹出错误,则可能更难追踪错误的根本原因。但是无论是 amerge还是rebaseinto 客户分支都应该为您描述的情况提供良好的工作流程。


推荐阅读