We have been using git-flow
for a while for the development of a software framework. We have the master
and development
branches in a single repository.
Recently, different customers became interested in buying the framework, which requires a customization of the framework per customer.
So far, we branched a new feature-customerXYZ
branch for each customer from the master, did the customization there and kept the branch open, after the customization was finished (which prevents 'infection' of the product master
/development
branch from the customization).
Parallel to this, the development on the framework itself goes on using the usual git-flow workflow on the product master
, development
, features
, hotfixes
and release
branches.
There are two common scenarios happening in this context for which I think our workflow cannot handle optimally:
Development of the feature-customerXYZ
branch can contain commits worthy of being implemented in the product master
/development
branch. Since the feature-customerXYZ
branch will never be closed, those commits have to be rebased
or cherrypicked
to the product branches, which requires extra work after the customization and is error prone.
Hotfixes discovered while a feature-customer
branch is open are handled by git-flow
by merging the opened hotfix
branches after the fix only to the product master
and development
branch, but are not merged into open feature-customer
branches (to be more precise: they are not merged into all open feature
branches).
Is there a git workflow that can handle this in a concise way? Is there a clever alternative instead of merge
, cherrypick
or rebase
of the commits to the product master
/develop
or the open feature
branches, respectively?
Of the three Git branch strategies we cover in this post, GitHub flow is the most simple. Because of the simplicity of the workflow, this Git branching strategy allows for Continuous Delivery and Continuous Integration. This Git branch strategy works great for small teams and web applications.
A centralized Git workflow enables all team members to make changes directly to the main branch (sometimes called the master branch or default branch), with every change logged in a running history. A centralized workflow involves every contributor committing to the main branch without using any other branch.
Traditional branching model Create one branch for each feature you need to work on. These branches will come from a base development branch, where all the dev code resides. Each developer will work on their respective feature branches until they are considered ready. Once ready, they'll be merged back to their source.
While it is theoretically possible to maintain customer deviations in dedicated branches as @VonC proposes, I dare to say that it is technically very difficult and does not scale.
Yes, you can have jobs (in Jenkins or something) that will automatically rebase your deviations against a master branch, but when it comes to tooling, you are on your own. As a minimum, be prepared for situations like:
Instead, I recommend to minimize the deviations, and after doing so, keep them all in a single branch, side-by-side.
This is typically possible if your project is composed of modules. You did not mention any details of your project, but most languages support some form of modularity, so I hope that this is your case, too.
This way, you can try to concentrate extension points for the deviations into minimum modules (ideally one), and have multiple variants of these modules in the project.
The advantages are obvious:
The only downside is, when you release your project for just one customer (with tagging and other ceremony), you do it also for all the others. It is not a big deal usually, and on the other hand, it motivates making the deviations feature-wise, which is good.
To minimize deviations, I recommend following techniques:
Just to summarize - minimize the deviations and build them all, side by side.
Spreading your codebase into multiple master branches (per-customer) will quickly become unmaintainable.
also use pull requests for merging the overall valid commits from
feature-customerXYZ
to develop?
Yes.
So the project maintainer can select which parts of the code are useful for the product master/develop?
No: the project maintainer should only accept PR that are trivial to merge (fast-forward), and run tests to validate the PR is working.
He/she is not in charge of selecting parts: only the developer should select them (as he/she is aware of what needs to be exposed to dev
/master
.
So for case 1, cherry-pick or rebase is still needed, in order to make a dedicated branch (separate from feature) which will then submitted to dev or master through a PR for validation.
For case 2, hotfix should be merged to develop, and each feature branch can, at its own time, rebase on the latest develop state, hence including the hostfix
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With