git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
JDJohn M. Dlugosz <ngnr63q02@sneakemail.com>
Date
Apr 22, 2009, 04:46 UTC
Message-ID
<gsm7fm$q31$1@ger.gmane.org>
In-Reply-To
<2729632a0904211224x6e2621caxf6c169d90b760530@mail.gmail.com>
skillzero@gmail.com wrote:
Show 16 quoted lines
> 
> 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
Previous: Jeff King
Message 9 of 9 in “How to merge from newer branch to older branches?”
  1. skillzero@gmail.comApr 21, 2009
  2. Jeff KingApr 21, 2009
  3. Junio C HamanoApr 22, 2009
  4. Jeff KingApr 22, 2009
  5. skillzero@gmail.comApr 22, 2009
  6. Jeff KingApr 22, 2009
  7. skillzero@gmail.comApr 22, 2009
  8. Jeff KingApr 22, 2009
  9. John M. DlugoszApr 22, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.