Difference in merge strategies from hoftix branches to master and develop branches

villasv Source

Using git flow it's noted that hotfix branches are branched from master and merged back to both master and develop.

However, it's plausible that merging hotfix to develop will cause merge conflicts, which is why my team is currently advocating to merge hotfix into master and then back from master do develop.

But I think that the scenarios that will create conflicts from hotfix to develop would also yield conflicts on merge to develop, so there's no real benefit here.

Even worse, because they always resolve conflicts inside GitHub Pull Requests, if there's a conflict from master to develop they'll create a commit on master solving it before merging to develop.

After all, are these non-issues? Is merging from hotfix to both master and develop really that important or is the second approach equally fine?

gitgit-flow

Answers

answered 6 months ago tkruse #1

The two approaches are functionally the same most of the time, in practice.

1       # last common commit
|\
| \
|  \
|   \
v    \
2     3  # master follows left side commits, develop follows right side
|\   /|
| \  .|
|  |  |
|. |  |
v/ |  |
4  |  |  # 4 merged into master from feature branch, contains 3
|  |  |
|  v  |
|  5  |  # hotfix commit 5
| /|  |
v/ |  |
6  |  |  # 6 fixes conflicts between 3 and 5
|   \ | 
|    \v 
|     A  # A also fixes conflicts between 3 and 5
 \
  \   .
   \  |
    \ |
     \v
      B # merge master with hotfix to develop

So your possibilities to merge to develop in A or B are that A will contain commits (1, 2, 3, 5) and B will contain (1, 2, 3, 4, 5, 6). There could be anything in 4 or 6 that is not desirable on the develop branch for whatever reason, but in practice I don't see what that could be.

Assuming commit 4 comes from some change on develop (already is on develop), then it is possible that commit 5 and commit 4 have merge conflicts. In that special case, the conflict would have to be resolved in both 6 and A, whereas merging into B would allow to resolve those conflicts only once in 6. Solving conflicts twice also has the potential of solving them (slightly) differently, causing further merge conflicts in the future.

comments powered by Disqus