[There seems to be a lot of similar information about related topics, but I still cannot find the answer.]
Suppose we have two diverging branches: stable and master (aiming at becoming the next stable):
----> split --> fix 1 --> [stable]
\
---> development --> more development ----> [master]
The branches diverged, for example, because fix 1 was done differently in master, as some development presented a better way to do it (but the development itself was too large in scope to merge it into the stable branch).
Now we have another bug 2, for which we need fix 2. While the branches are already diverged, the affected files are absolutely the same in both stable in master and the fix would look exactly the same too.
What is the best way to apply identical changes to two diverged branches? Fix in one, then cherry-pick? Or is there a better solution?
The problem with cherry-pick is that you don't have an explicit link between both commits, defeating the purpose of keeping track of changes. Just do a merge:
X
of master
and stable
fix_bug2
at commit X
fix_bug2
into stable
fix_bug2
into master