git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Rebasing multiple branches
@ 2010-12-21 13:40 Leonid Podolny
  2010-12-21 14:06 ` Johannes Sixt
  0 siblings, 1 reply; 6+ messages in thread
From: Leonid Podolny @ 2010-12-21 13:40 UTC (permalink / raw)
  To: git

Hi,
I need to rebase a rather complicated formation of branches.

My situation is like this (I hope ASCII graphics survive the sending):

         B--o--o--o--o--o--o  <--branch A
        /                   \
o--o--A--o--E  <--master    C--o--o--o--D  <--branch C
        \                   /
         C--o--o--o--o--o--o  <--branch B

I would like to rebase all three branches A, B and C onto commit E, and 
it's very important to keep the information about merges. For instance, 
if I take commit C and rebase it onto D, it serializes all the 
intermediate commits.
The only solution I managed to come up with is as follows:
- Take branch A and rebase it onto D (branch A').
- Same with branch B.
- Open a new branch C' from commit E.
- Merge A' and B' into C'.
- Manually cherry-pick all commits from commit C to commit D into branch C'.


The last step is way too ugly to be the only possible solution :)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Rebasing multiple branches
  2010-12-21 13:40 Rebasing multiple branches Leonid Podolny
@ 2010-12-21 14:06 ` Johannes Sixt
  2010-12-22 14:36   ` Enrico Weigelt
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Sixt @ 2010-12-21 14:06 UTC (permalink / raw)
  To: Leonid Podolny; +Cc: git

Am 12/21/2010 14:40, schrieb Leonid Podolny:
>         B--o--o--o--o--o--o  <--branch A
>        /                   \
> o--o--A--o--E  <--master    C--o--o--o--D  <--branch C
>        \                   /
>         C--o--o--o--o--o--o  <--branch B
> 
> I would like to rebase all three branches A, B and C onto commit E,...

git rebase master A
git rebase master B
git merge A
git rebase -i HEAD C

The last rebase I propose as interactive so that you can remove those
commits before D~3 that you have already rebased, because they are likely
to conflict unnecessarily, and you would --skip them anyway.

(Note: "C" is the branch C, not the commit C. Please make labels
unambiguous next time.)

-- Hannes

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Rebasing multiple branches
  2010-12-21 14:06 ` Johannes Sixt
@ 2010-12-22 14:36   ` Enrico Weigelt
  2010-12-22 14:54     ` Leonid Podolny
  0 siblings, 1 reply; 6+ messages in thread
From: Enrico Weigelt @ 2010-12-22 14:36 UTC (permalink / raw)
  To: git

* Johannes Sixt <j.sixt@viscovery.net> wrote:
> Am 12/21/2010 14:40, schrieb Leonid Podolny:
> >         B--o--o--o--o--o--o  <--branch A
> >        /                   \
> > o--o--A--o--E  <--master    C--o--o--o--D  <--branch C
> >        \                   /
> >         C--o--o--o--o--o--o  <--branch B
> > 
> > I would like to rebase all three branches A, B and C onto commit E,...
> 
> git rebase master A
> git rebase master B
> git merge A
> git rebase -i HEAD C
> 
> The last rebase I propose as interactive so that you can remove those
> commits before D~3 that you have already rebased, because they are likely
> to conflict unnecessarily, and you would --skip them anyway.

Why not this way ?

git checkout D
git rebase -p -i D~3 --onto C'

(C' is the merged branch of A' and B').


So:

git checkout branch_A -b rebasing_A
git rebase master			# rebase old A to master
git checkout branch_B -b rebasing_B
git rebase master			# rebase old B to master
git checkout -b rebased_merge
git merge rebasing_A			# we're on B', merge in A'
git checkout branch_C
git rebase -p -i C --onto rebased_merge # set D~3..D ontop of it


cu
-- 
----------------------------------------------------------------------
 Enrico Weigelt, metux IT service -- http://www.metux.de/

 phone:  +49 36207 519931  email: weigelt@metux.de
 mobile: +49 151 27565287  icq:   210169427         skype: nekrad666
----------------------------------------------------------------------
 Embedded-Linux / Portierung / Opensource-QM / Verteilte Systeme
----------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Rebasing multiple branches
  2010-12-22 14:36   ` Enrico Weigelt
@ 2010-12-22 14:54     ` Leonid Podolny
  2010-12-30  5:35       ` Enrico Weigelt
  0 siblings, 1 reply; 6+ messages in thread
From: Leonid Podolny @ 2010-12-22 14:54 UTC (permalink / raw)
  To: weigelt; +Cc: git

On 12/22/2010 04:36 PM, Enrico Weigelt wrote:
> Why not this way ?
>
> git checkout D
> git rebase -p -i D~3 --onto C'
>
> (C' is the merged branch of A' and B').
>
>
> So:
>
> git checkout branch_A -b rebasing_A
> git rebase master			# rebase old A to master
> git checkout branch_B -b rebasing_B
> git rebase master			# rebase old B to master
> git checkout -b rebased_merge
> git merge rebasing_A			# we're on B', merge in A'
> git checkout branch_C
> git rebase -p -i C --onto rebased_merge # set D~3..D ontop of it
>
>
> cu

Ah, nice. I didn't notice the -p option. However, the man page advises 
against using -p and -i together.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Rebasing multiple branches
  2010-12-22 14:54     ` Leonid Podolny
@ 2010-12-30  5:35       ` Enrico Weigelt
  2010-12-31 14:55         ` Thomas Rast
  0 siblings, 1 reply; 6+ messages in thread
From: Enrico Weigelt @ 2010-12-30  5:35 UTC (permalink / raw)
  To: git

* Leonid Podolny <leonidp.lists@gmail.com> wrote:

> Ah, nice. I didn't notice the -p option. However, the man page advises 
> against using -p and -i together.

Last time I checked, -i required -p ...


cu
-- 
----------------------------------------------------------------------
 Enrico Weigelt, metux IT service -- http://www.metux.de/

 phone:  +49 36207 519931  email: weigelt@metux.de
 mobile: +49 151 27565287  icq:   210169427         skype: nekrad666
----------------------------------------------------------------------
 Embedded-Linux / Portierung / Opensource-QM / Verteilte Systeme
----------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Rebasing multiple branches
  2010-12-30  5:35       ` Enrico Weigelt
@ 2010-12-31 14:55         ` Thomas Rast
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Rast @ 2010-12-31 14:55 UTC (permalink / raw)
  To: weigelt; +Cc: git, leonidp.lists, Johannes Sixt

Please don't cull the Cc lists.  Unless he's subscribed, Leonid never
got your reply!

Enrico Weigelt wrote:
> * Leonid Podolny <leonidp.lists@gmail.com> wrote:
> 
> > Ah, nice. I didn't notice the -p option. However, the man page advises 
> > against using -p and -i together.
> 
> Last time I checked, -i required -p ...

-p internally implies -i, but the user doesn't have to know that ;-)

The problem is that the todo file language is not expressive enough
for what -p needs to do.  Running a rebase -p without changing the
todo file should behave reasonably.  On the other hand, if you
rearrange or extend the todo file in many cases that gives unexpected
results.

Hence the recommendation to not use it with -i.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-12-31 14:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-21 13:40 Rebasing multiple branches Leonid Podolny
2010-12-21 14:06 ` Johannes Sixt
2010-12-22 14:36   ` Enrico Weigelt
2010-12-22 14:54     ` Leonid Podolny
2010-12-30  5:35       ` Enrico Weigelt
2010-12-31 14:55         ` Thomas Rast

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).