Hi,
In this case, Git can't be a mind reader as it doesn't know that you will
want all of the branches to be rebased, so you will need to rebase them in
the appropriate order..
In the example you accidently chose the wrong order, and start-end points.
On each rebase, the current time is used for the new commits, so you will
get different commit hashes even though the commit content (other than
commit date) is identical. This causes the branches to appear disjoint
without a common merge point.
The best trick is to start near the root of the tree, and grow the rebase
outward, and use the magic invocation of --onto to put the side branches
into their correct (new) locations (selecting the right portions if you
can).
In the A-B case you could simply re-point the branch A at the new mid point
in the master-B' sequence. (see update-ref IIRC).
In the ABC case, you use rebase --onto for the A-C part onto the new head of
"A" at A'.
HTH.
Philip
----- Original Message -----
From: "Wink Saville" <w...@saville.com>
To: "Git for human beings" <git-users@googlegroups.com>
Sent: Saturday, February 10, 2018 5:50 PM
Subject: [git-users] How to properly rebase branches with common histories
I created branch "A" off master did multiple commits. I then made a branch
"B" off "A"
and add multiple commits to "B". So I have a nice linear history:
Master A B
o - - - - -| - - - -|
I then updated master from upstream and now have Master'
Master A B
o - - - - -| - - - -|
\
\- - - - - - |
Master'
I then rebased B onto Master' followed by rebasing A on to master and got
this:
Master A B
o - - - - -|- - - -|
\ Master'
\- - - - - - |
|\ a B'
| \- - - - -| - - - -|
\
\ A'
- - - - -|
The "a" represents the commit whose content is the same as A and A'.
As expected if I "git diff A' a" they are identical.
How could have I done the rebase such that A' and B' would continue
to have a linear history?
How would I rebase if a third branch, C off A was in the mix as well:
Master A B
o - - - - -|- - - -|
\- -|
C
So after rebasing we'd have:
Master A B
o - - - - -|- - - -|
\ \- -|
\ C
\ Master'
\- - - - - - |
\ A' B'
\- - - - -|- - - -|
\- -|
C'
-- Wink
--
You received this message because you are subscribed to the Google Groups
"Git for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Git for
human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.