Subject: Re: How to merge from newer branch to older branches?

From: "John M. Dlugosz" <[email-masked]>
Date: Tue, 21 Apr 2009 23:46:32 -0500

[email-masked] wrote:
> 
> future o-o-o-o-o-o-o
>         \   \       \
> 1.2          o-o-o   \
>           \           \
> 1.1        o-o-o       \
>                         \
> feature                  o-o-o
>                          a b c
> 
> Is cherry-picking the best way? It seems pretty tedious because I have
> to do each commit in reverse order (although I could script it). I was
> hoping there was a way to say "apply all the changes from when
> "feature" branched up to its tip". I would also like to preserve the
> commit history rather than just making making one big commit of all
> the changes.

I think any other command that "just" moves those deltas would be the exact equivalent of 
cherry picking in terms of the conflicts it sees.

You can, however, collapse a,b,c into one commit and pick that into each place it is 
needed, calling it a good comment for the whole feature.  That might be more difficult to 
merge than doing one at a time, but if not, and the whole string is tedious (i.e. 50 
instead of 3, mostly incremental typo fixes and stuff) I can see the benefit of making it 
a gestalt.

Furthermore... (thinking out loud)... the conflicts are caused by things after the other 
branches, right?  After you do the resolving for (say) 1.2, then instead of picking a,b,c 
again (with the same merge issues), pick the one you put onto 1.2 already.  Work your way 
that way from branches that came off nearest to the original feature, back down toward the 
  root.  Each time pick the one you just planted, because it already contains merges part 
way down.  Then you only have to deal with the changes between those two branches.

So that's what I'd do:  pick a, b, and c onto the most recient other branch (1.2 in your 
drawing), fixing merge as I go.  Then reset mixed back to the original tip before the 
picks, and commit everything with a good name for the feature.  Then, pick that onto the 
next newest branch (1,1 in your drawing), etc.

--John