Search code examples
gitgit-branchgit-mergegit-rebasegit-cherry-pick

How to share a fix between previous releases and current work in the cycle workflow?


I am wondering which route should I take, a cherry-pick or something else?

I have this branching tree:

          ReleaseX
       ^
      /
Master --> ReleaseY
   |
   V
WorkInProgress
   |        |        
   V        V
FeatureX  FeatureY    .. etc

So WorkInProgress branches off of Master, and when WorkInProgress is "done", I do "Pull Request" from it to Master, and then I branch off of Master to a new Branch and call it ReleaseX

This allows me to support releases and do hot-fixes on any Release branch separately.

I have two cases for my question here:

  • Do a hotfix on ReleaseX and then apply it on ReleaseY
  • Do a hotfix for ReleaseX, ReleaseY and also WorkInProgress

Is Cherry-Pick the way to go?


Solution

  • This sort of branching structure is something I would only recommend when you have to maintain ReleaseX and ReleaseY at the same time (if you do, good luck)

    In this situation I would advice fixing the bug on the Release branch where it is found first (in a separate hotfix branch which you merge back in). Then cherry-picking those commits to the other Release branches.

    Generally I like to avoid cherry-picking as it creates hard to follow duplicate commits, but the action is better than modifying history (rebasing) commits that have been shared and marked as release.