Git – Branching Strategy for Long-running Unreleased Code

branchinggitmaintenanceversion control

At our team, in addition to individual units of work (Stories), we have longer-running themes of work (Epics). Multiple stories make an epic.

Traditionally we've had feature branches for each Story, and merged those straight to master when they pass QA. However, we'd like to start holding back on release of completed stories in an Epic until the Epic is deemed "feature complete". We'd only release these features to production when the entire Epic is closed. Furthermore, we have a nightly build server – we'd like all closed Stories (including those that are part of incomplete Epics) to be deployed to this nightly server automatically.

Are there any suggestions on how to manage our repo to achieve this? I've considered introducing "epic branches", where we'd merging closed stories to the related epic branch instead of direct to master, but my concerns are:

  • I worry about the merge conflicts that may arise if epic branches are kept open for long
  • Nightly builds would require merging all epic branches into a "nightly build" branch. Again, merge conflicts could arise, and this is to be done automatically

Best Answer

Simple suggestion: don't do that.

git branches are not for long-running forks of the code, as discussed here and here. Branches are best treated as transient things used to organize commits by an individual developer on a day-to-day level. So if they have a name that corresponds to something a project manager (let alone end user) might care about you are doing something wrong.

Recommended practice is to use continuous integration with feature toggles or branch-by-abstraction to ensure that:

  • all code is integrated at all times (at least every day, preferably more often)
  • what gets deployed is under explicit control.
Related Topic