{"thread":{"id":"26113","subject":"Rebasing multiple branches","startedAt":"2010-12-21T13:40:43Z","lastAt":"2010-12-31T14:55:26Z","messageCount":6,"participants":["Leonid Podolny","Johannes Sixt","Enrico Weigelt","Thomas Rast"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"158434","messageId":"4D10AE5B.2080700@gmail.com","threadId":"26113","inReplyTo":null,"subject":"Rebasing multiple branches","fromName":"Leonid Podolny","fromEmail":"leonidp.lists@gmail.com","sentAt":"2010-12-21T13:40:43Z","receivedAt":"2010-12-21T13:40:43Z","isPatch":false,"sender":{"key":"leonidp.lists@gmail.com","avatar":null},"body":"Hi,\nI need to rebase a rather complicated formation of branches.\n\nMy situation is like this (I hope ASCII graphics survive the sending):\n\n         B--o--o--o--o--o--o  <--branch A\n        /                   \\\no--o--A--o--E  <--master    C--o--o--o--D  <--branch C\n        \\                   /\n         C--o--o--o--o--o--o  <--branch B\n\nI would like to rebase all three branches A, B and C onto commit E, and \nit's very important to keep the information about merges. For instance, \nif I take commit C and rebase it onto D, it serializes all the \nintermediate commits.\nThe only solution I managed to come up with is as follows:\n- Take branch A and rebase it onto D (branch A').\n- Same with branch B.\n- Open a new branch C' from commit E.\n- Merge A' and B' into C'.\n- Manually cherry-pick all commits from commit C to commit D into branch C'.\n\n\nThe last step is way too ugly to be the only possible solution :)\n"},{"id":"158436","messageId":"4D10B44D.5090309@viscovery.net","threadId":"26113","inReplyTo":"4D10AE5B.2080700@gmail.com","subject":"Re: Rebasing multiple branches","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2010-12-21T14:06:05Z","receivedAt":"2010-12-21T14:06:05Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 12/21/2010 14:40, schrieb Leonid Podolny:\n>         B--o--o--o--o--o--o  <--branch A\n>        /                   \\\n> o--o--A--o--E  <--master    C--o--o--o--D  <--branch C\n>        \\                   /\n>         C--o--o--o--o--o--o  <--branch B\n> \n> I would like to rebase all three branches A, B and C onto commit E,...\n\ngit rebase master A\ngit rebase master B\ngit merge A\ngit rebase -i HEAD C\n\nThe last rebase I propose as interactive so that you can remove those\ncommits before D~3 that you have already rebased, because they are likely\nto conflict unnecessarily, and you would --skip them anyway.\n\n(Note: \"C\" is the branch C, not the commit C. Please make labels\nunambiguous next time.)\n\n-- Hannes\n"},{"id":"158488","messageId":"20101222143654.GA4829@nibiru.local","threadId":"26113","inReplyTo":"4D10B44D.5090309@viscovery.net","subject":"Re: Rebasing multiple branches","fromName":"Enrico Weigelt","fromEmail":"weigelt@metux.de","sentAt":"2010-12-22T14:36:55Z","receivedAt":"2010-12-22T14:36:55Z","isPatch":false,"sender":{"key":"weigelt@metux.de","avatar":null},"body":"* Johannes Sixt <j.sixt@viscovery.net> wrote:\n> Am 12/21/2010 14:40, schrieb Leonid Podolny:\n> >         B--o--o--o--o--o--o  <--branch A\n> >        /                   \\\n> > o--o--A--o--E  <--master    C--o--o--o--D  <--branch C\n> >        \\                   /\n> >         C--o--o--o--o--o--o  <--branch B\n> > \n> > I would like to rebase all three branches A, B and C onto commit E,...\n> \n> git rebase master A\n> git rebase master B\n> git merge A\n> git rebase -i HEAD C\n> \n> The last rebase I propose as interactive so that you can remove those\n> commits before D~3 that you have already rebased, because they are likely\n> to conflict unnecessarily, and you would --skip them anyway.\n\nWhy not this way ?\n\ngit checkout D\ngit rebase -p -i D~3 --onto C'\n\n(C' is the merged branch of A' and B').\n\n\nSo:\n\ngit checkout branch_A -b rebasing_A\ngit rebase master\t\t\t# rebase old A to master\ngit checkout branch_B -b rebasing_B\ngit rebase master\t\t\t# rebase old B to master\ngit checkout -b rebased_merge\ngit merge rebasing_A\t\t\t# we're on B', merge in A'\ngit checkout branch_C\ngit rebase -p -i C --onto rebased_merge # set D~3..D ontop of it\n\n\ncu\n-- \n----------------------------------------------------------------------\n Enrico Weigelt, metux IT service -- http://www.metux.de/\n\n phone:  +49 36207 519931  email: weigelt@metux.de\n mobile: +49 151 27565287  icq:   210169427         skype: nekrad666\n----------------------------------------------------------------------\n Embedded-Linux / Portierung / Opensource-QM / Verteilte Systeme\n----------------------------------------------------------------------\n"},{"id":"158489","messageId":"4D121136.6050906@gmail.com","threadId":"26113","inReplyTo":"20101222143654.GA4829@nibiru.local","subject":"Re: Rebasing multiple branches","fromName":"Leonid Podolny","fromEmail":"leonidp.lists@gmail.com","sentAt":"2010-12-22T14:54:46Z","receivedAt":"2010-12-22T14:54:46Z","isPatch":false,"sender":{"key":"leonidp.lists@gmail.com","avatar":null},"body":"On 12/22/2010 04:36 PM, Enrico Weigelt wrote:\n> Why not this way ?\n>\n> git checkout D\n> git rebase -p -i D~3 --onto C'\n>\n> (C' is the merged branch of A' and B').\n>\n>\n> So:\n>\n> git checkout branch_A -b rebasing_A\n> git rebase master\t\t\t# rebase old A to master\n> git checkout branch_B -b rebasing_B\n> git rebase master\t\t\t# rebase old B to master\n> git checkout -b rebased_merge\n> git merge rebasing_A\t\t\t# we're on B', merge in A'\n> git checkout branch_C\n> git rebase -p -i C --onto rebased_merge # set D~3..D ontop of it\n>\n>\n> cu\n\nAh, nice. I didn't notice the -p option. However, the man page advises \nagainst using -p and -i together.\n"},{"id":"158748","messageId":"20101230053530.GA10511@nibiru.local","threadId":"26113","inReplyTo":"4D121136.6050906@gmail.com","subject":"Re: Rebasing multiple branches","fromName":"Enrico Weigelt","fromEmail":"weigelt@metux.de","sentAt":"2010-12-30T05:35:31Z","receivedAt":"2010-12-30T05:35:31Z","isPatch":false,"sender":{"key":"weigelt@metux.de","avatar":null},"body":"* Leonid Podolny <leonidp.lists@gmail.com> wrote:\n\n> Ah, nice. I didn't notice the -p option. However, the man page advises \n> against using -p and -i together.\n\nLast time I checked, -i required -p ...\n\n\ncu\n-- \n----------------------------------------------------------------------\n Enrico Weigelt, metux IT service -- http://www.metux.de/\n\n phone:  +49 36207 519931  email: weigelt@metux.de\n mobile: +49 151 27565287  icq:   210169427         skype: nekrad666\n----------------------------------------------------------------------\n Embedded-Linux / Portierung / Opensource-QM / Verteilte Systeme\n----------------------------------------------------------------------\n"},{"id":"158782","messageId":"201012311555.26354.trast@student.ethz.ch","threadId":"26113","inReplyTo":"20101230053530.GA10511@nibiru.local","subject":"Re: Rebasing multiple branches","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-12-31T14:55:26Z","receivedAt":"2010-12-31T14:55:26Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Please don't cull the Cc lists.  Unless he's subscribed, Leonid never\ngot your reply!\n\nEnrico Weigelt wrote:\n> * Leonid Podolny <leonidp.lists@gmail.com> wrote:\n> \n> > Ah, nice. I didn't notice the -p option. However, the man page advises \n> > against using -p and -i together.\n> \n> Last time I checked, -i required -p ...\n\n-p internally implies -i, but the user doesn't have to know that ;-)\n\nThe problem is that the todo file language is not expressive enough\nfor what -p needs to do.  Running a rebase -p without changing the\ntodo file should behave reasonably.  On the other hand, if you\nrearrange or extend the todo file in many cases that gives unexpected\nresults.\n\nHence the recommendation to not use it with -i.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"}]}