Repository navigation
Description
Hi! Big fan of this workflow, thanks for all the write up around it. It has been working great for us with our CI/CD.
One question about merging topics into other topics when they depend on each other.
Your recommendation is to:
create your topic and merge the other topic into it. This explicitly records the dependency relationship between the topics, and puts the commit resolutions (if any) on the right branch.
But
if topic B depends on another topic A that has not yet graduated to master, topic A may be merged into topic B. This complicates interactive branch rebases so this should be avoided when possible, however if necessary, git should handle this situation without too much problem.
Interactive rebasing to clean up commit history etc is an obvious pain point here, that would be nice to avoid.
But my main concern is this use case:
If Topic B depends on Topic A and both are in development, I merge Topic A into Topic B and do some work. But Topic A is still being developed and I need to pull in the newest features again into Topic B, a second merge commit in this case would complicate rebasing and history even more. What would be your thoughts in this case?
Instead of merging topic dependencies, wouldn't it be better to keep them rebased during development? And maybe only merge the dependency when it graduates by first getting rid of the depending commits:
git rebase --onto master topic-a topic-b
and then merge topic a into topic b to record the dependency?
While this is a solution, it's not the cleanest one imho, as it relies on best effort from everyone to rebase and merge correctly when necessary.
I'd love to hear any ideas for a better approach :)
Activity
rocketraman commentedon Dec 3, 2020
Great to hear!
Personally I agree and tend to operate this way myself, assuming this is what you mean: if developing on
topic-b, I tend towards merging in dependent topics liketopic-aas my first commit ontopic-b. Even if I only realizetopic-adepends ontopic-bafter I've committed a bunch of stuff intotopic-b, I'll still use a rebase to rewind to master, merge intopic-a, and then add mytopic-bcommits on top. Whentopic-ahas been updated, I'll either rebasetopic-bso so that the latest version oftopic-ais still the first merge commit, or occasionally if it has only changed in minor ways (and hasn't been rebased itself), I'll sometimes take a shortcut and just merge it at the head oftopic-b.I just find mentally that is easier to follow my topic history that way be ensuring my work is "on top" of any other major work.
Note also that with the existence of
rebase -i -r(there is an issue open to document this here: #6) this is all quite easy to do!So here
topic-ahas graduated tomasteralready? If so, yes, I'll often do this too, though its definitely not necessary. I won't do it as a rule, but really only ifmasterhas other things in it I want, and iftopic-ahas graduated, I no longer need it merged intotopic-b.I might be misunderstanding you. If
topic-ahas graduated and you're rebasingtopic-b, then this will be a no-op.rocketraman commentedon Dec 4, 2020
@Tomasvrba thoughts on my comments above?
Tomasvrba commentedon Dec 7, 2020
Thanks for the input and the quick reply.
Agreed with everything and our workflow setup is also to keep all topic commits "on top" of other dependencies so it's easy to tell which commits actually belong to a certain topic.
At this point I think rebase with
--rebase-mergesis the way to go, I'll test it out with a situation from last week where we had about 5 topics that needed to graduate that all depended on each other in some way.As to the last point where I mentioned
git rebase --onto, no,topic-ahad not graduated to master in my example, buttopic-bwas ready for graduating tonext/pufor testing. But that's not a very good example anyway, since it depends ontopic-asotopic-aneeds to also be finished first in any case.