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

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

From
Sskillzero@gmail.com <skillzero@gmail.com>
Date
Apr 22, 2009, 17:44 UTC
Message-ID
<2729632a0904221044q20e6cabau7dd06b3020a8ce49@mail.gmail.com>
In-Reply-To
<7vmya946fg.fsf@gitster.siamese.dyndns.org>

Based on the help from this discussion and the rebase documenation, what I ended up doing that seemed to require the fewest conflicts is to use git merge-base to find the merge-base of master and 1.1 (the oldest branch I wanted the feature) then I found the commit immediately before the first commit on the feature branch (feature~3 in this case or commit a^). Then I rebased feature:

git rebase --onto merge-base-of-1.1-and-master feature-before-first feature
Turning this (hopefully not mangled by gmail):
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
into this:
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

I can merge 'feature' into 1.1, 1.2, etc. then theoretically, I should be able to apply bug fixes to 'feature' later and re-merge into 1.1, 1.2, etc. to pick up just the bug fixes, right?

When I merged 'feature' into 'v1.1', it resulted in the same conflicts I originally ran into when cherry-picking, but when I looked at it, I realized this was because I had manually integrated some changes into 1.1 from master (I'm trying to move our tree from CVS to git so I had to manually move in some stuff from CVS instead of doing a proper git merge).

It seems like this merge conflict is going to cause problems if I try to re-merge to pick up a bug fix to 'feature' in the future. Looking at the documentation, it sounds like 'git rerere' can help by re-applying the manual conflict resolution I did?

BTW...Is there a way to find the first commit of a branch? I had to just look at the log manually to see what I remembered to be the first commit.

Previous: Jeff KingNext: Jeff King
Message 5 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.