Git: Fixing a bug affecting two branches

Posted by Aram Kocharyan on Programmers See other posts from Programmers or by Aram Kocharyan
Published on 2012-06-24T10:35:16Z Indexed on 2012/06/24 15:24 UTC
Read the original article Hit count: 544

Filed under:
|
|

I'm basing my Git repo on http://nvie.com/posts/a-successful-git-branching-model/ and was wondering what happens if you have this situation:

enter image description here

Say I'm developing on two feature branches A and B, and B requires code from A. The X node introduces an error in feature A which affects branch B, but this is not detected at node Y where feature A and B were merged and testing was conducted before branching out again and working on the next iteration.

As a result, the bug is found at node Z by the people working on feature B. At this stage it's decided that a bugfix is needed. This fix should be applied to both features, since the people working on feature A also need the bug fixed, since its part of their feature.

Should a bugfix branch be created from the latest feature A node (the one branching from node Y) and then merged with feature A? After which both features are merged into develop again and tested before branching out?

The problem with this is that it requires both branches to merge to fix the issue. Since feature B doesn't touch code in feature A, is there a way to change the history at node Y by implementing the fix and still allowing the feature B branch to remain unmerged yet have the fixed code from feature A?

Mildly related: Git bug branching convention

© Programmers or respective owner

Related posts about git

Related posts about bug