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

What I want rebase to do

From
Dale R. Worley <worley@alum.mit.edu>
Date
Mar 6, 2013, 18:55 UTC
Message-ID
<201303061855.r26ItKtM018797@freeze.ariadne.com>
In-Reply-To
<7vppzex2pq.fsf@alter.siamese.dyndns.org>
This is how I see what rebase should do:
The simple case for rebase starts from
               P---Q---R---S master
                    \
                     A---B---C topic
Then "git checkout topic ; git rebase master" will change it to
               P---Q---R---S master
                            \
                             A'--B'--C' topic
A' is created by a three-way merge that can be symbolized
        Q-->S
        |   |
        v   v
        A-->A'

That is, Q, applying the changes from Q to A and the changes from Q to S, becomes A'.

After that
        A-->A'
        |   |
        v   v
        B-->B'
        |   |
        v   v
        C-->C'
A more complex case is when there is a merge from an external source
               P---Q---R---S master
                    \
                     A---M---C topic
                        /
                    ---X
We want to produce
               P---Q---R---S master
                            \
                             A'--M'--C' topic
                                /
                            ---X
So we have to merge
        Q-->S
        |   |
        v   v
        A-->A'
        |   |
        v   v
        M-->M'
        |   |
        v   v
        C-->C'

Any "evil" changes in M will be in the changes A->M (along with the changes introduced from X), and so they will be reincorporated in A'->M'. M' lists A' and X as its parents. (And not M!)

If there is an internal merge in the topic branch, things look like this

               P---Q---R---S master
                    \
                     \   B
                      \ / \
                       A   M---D topic
                        \ /
                         C
and we want to produce this
               P---Q---R---S master
                            \
                             \    B'
                              \  /  \
                               A'    M'--D' topic
                                 \  /
                                  C'
Which can be done with these merges
        Q-->S
        |   |
        v   v
        A-->A'        A-->A'
        |   |         |   | 
        v   v         v   v 
        B-->B'        C-->C'

There are two choices for constructing M' (which ought to produce the same results under ordinary circumstances)

        B-->B'        C-->C'
        |   |         |   | 
        v   v         v   v 
        M-->M'        M-->M'
and finally
        M-->M'
        |   |
        v   v
        D-->D'
Dale
Previous: Junio C HamanoNext: Thomas Rast
Message 5 of 13 in “"git rebase" loses the additional changes in "evil" merges”
  1. Dale R. WorleyMar 4, 2013
  2. Junio C HamanoMar 4, 2013
  3. Thomas RastMar 4, 2013
  4. Junio C HamanoMar 4, 2013
  5. What I want rebase to doDale R. Worley, Mar 6, 2013
  6. Thomas RastMar 7, 2013
  7. Johannes SixtMar 7, 2013
  8. Junio C HamanoMar 7, 2013
  9. Dale R. WorleyMar 7, 2013
  10. Dale WorleyMar 5, 2013
  11. Junio C HamanoMar 5, 2013
  12. Philip OakleyMar 5, 2013
  13. Junio C HamanoMar 5, 2013

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.