Home > Software engineering >  How to sync a bug fix across all branches?
How to sync a bug fix across all branches?

Time:09-16

Assume a scenario where I have a repo and there are 3 branches, master - where all the deployment code lives, and two feature branches A and B which are being used by different developers and have commits that can't be discarded. Suppose there is a bug that is affecting the work on branch A and branch B. What will be the ideal way to complete this task? What I've been doing is creating a 3rd branch 'C', implementing the fixes, and then merging it with the master, pushing it to the origin, pulling the changes on the devs' machine, and merging the branches A and B with the master. But it seems it isn't the ideal way to do it. It somehow feels really jank. Is there a better way to do it?

Also, if there are some pro tips for newbies like me, please shower us with your wisdom.

CodePudding user response:

Since you do not abhor merges, the ideal procedure is:

  • You create a new branch C that forks from master before A and B were forked off. Ideally, that is the commit that introduced the bug that you are fixing.

  • You merge C into master, A, and B.

You should not merge C into master and then the resulting master into A and B because you get all of master's commits into A and B, and that is unnecessary complexity that you do not want at this point.

  •  Tags:  
  • git
  • Related