{"thread":{"id":"24336","subject":"Rebasing a merged branch","startedAt":"2010-07-08T11:52:08Z","lastAt":"2010-07-10T07:19:55Z","messageCount":3,"participants":["Peter Krefting","Chris Frey","Peter Baumann"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"145117","messageId":"alpine.DEB.2.00.1007081247410.18908@ds9.cixit.se","threadId":"24336","inReplyTo":null,"subject":"Rebasing a merged branch","fromName":"Peter Krefting","fromEmail":"peter@softwolves.pp.se","sentAt":"2010-07-08T11:52:08Z","receivedAt":"2010-07-08T11:52:08Z","isPatch":false,"sender":{"key":"peter@softwolves.pp.se","avatar":"https://avatars.githubusercontent.com/u/990764?v=4"},"body":"Hi!\n\nIf I slightly modify the example from the git-rebase manual page to look \nlike this:\n\n   o---o---o---o  master\n          \\\n           o---o---o---o---o  topicA\n            \\     /\n             A---B---C---D  topicB\n\n(topicA has merged \"B\" into its history; its first-parent from the line of \n\"o\"s).\n\nIf I now do a \"git rebase --onto master topicA topicB\", I only get commit C \nand D, as it sees A and B as being part of both branches.\n\nIs there a way to make git rebase pick up A, B, C and D (and only them)?\n\nI.e., I would like \"all commits on topicB which are not in topicA's \n--first-parent history\".\n\n\n\nI eventually came up with\n\n   git rebase --onto master $(git rev-list topicA ^topicB | tail -1) topicB\n\nbut am thinking that it ought to be expressable in a simpler way?\n\n-- \n\\\\// Peter - http://www.softwolves.pp.se/\n"},{"id":"145263","messageId":"20100710065541.GB15600@foursquare.net","threadId":"24336","inReplyTo":"alpine.DEB.2.00.1007081247410.18908@ds9.cixit.se","subject":"Re: Rebasing a merged branch","fromName":"Chris Frey","fromEmail":"cdfrey@foursquare.net","sentAt":"2010-07-10T06:55:41Z","receivedAt":"2010-07-10T06:55:41Z","isPatch":false,"sender":{"key":"cdfrey@foursquare.net","avatar":null},"body":"On Thu, Jul 08, 2010 at 12:52:08PM +0100, Peter Krefting wrote:\n> Hi!\n> \n> If I slightly modify the example from the git-rebase manual page to look \n> like this:\n> \n>   o---o---o---o  master\n>          \\\n>           o---o---o---o---o  topicA\n>            \\     /\n>             A---B---C---D  topicB\n> \n> (topicA has merged \"B\" into its history; its first-parent from the line of \n> \"o\"s).\n> \n> If I now do a \"git rebase --onto master topicA topicB\", I only get commit C \n> and D, as it sees A and B as being part of both branches.\n> \n> Is there a way to make git rebase pick up A, B, C and D (and only them)?\n> \n> I.e., I would like \"all commits on topicB which are not in topicA's \n> --first-parent history\".\n\n\nI'm no expert on rebase --onto, but aren't you trying to rebase so that\nthe tree looks like this afterward?\n\n\n   o---o---o---o  master\n            \\   \\\n             \\   A---B---C---D  topicB\n              \\\n               o---o---o---o---o  topicA\n                \\     /\n                 A---B\n \nIn which case, won't this work?\n\n\tgit checkout topicB\n\tgit rebase master\n\n- Chris\n"},{"id":"145265","messageId":"20100710071955.GA12251@m62s10.vlinux.de","threadId":"24336","inReplyTo":"20100710065541.GB15600@foursquare.net","subject":"Re: Rebasing a merged branch","fromName":"Peter Baumann","fromEmail":"waste.manager@gmx.de","sentAt":"2010-07-10T07:19:55Z","receivedAt":"2010-07-10T07:19:55Z","isPatch":false,"sender":{"key":"waste.manager@gmx.de","avatar":null},"body":"On Sat, Jul 10, 2010 at 02:55:41AM -0400, Chris Frey wrote:\n> On Thu, Jul 08, 2010 at 12:52:08PM +0100, Peter Krefting wrote:\n> > Hi!\n> > \n> > If I slightly modify the example from the git-rebase manual page to look \n> > like this:\n> > \n> >   o---o---o---o  master\n> >          \\\n> >           o---o---o---o---o  topicA\n> >            \\     /\n> >             A---B---C---D  topicB\n> > \n> > (topicA has merged \"B\" into its history; its first-parent from the line of \n> > \"o\"s).\n> > \n> > If I now do a \"git rebase --onto master topicA topicB\", I only get commit C \n> > and D, as it sees A and B as being part of both branches.\n> > \n> > Is there a way to make git rebase pick up A, B, C and D (and only them)?\n> > \n> > I.e., I would like \"all commits on topicB which are not in topicA's \n> > --first-parent history\".\n> \n> \n> I'm no expert on rebase --onto, but aren't you trying to rebase so that\n> the tree looks like this afterward?\n> \n> \n>    o---o---o---o  master\n>             \\   \\\n>              \\   A---B---C---D  topicB\n>               \\\n>                o---o---o---o---o  topicA\n>                 \\     /\n>                  A---B\n>  \n> In which case, won't this work?\n> \n> \tgit checkout topicB\n> \tgit rebase master\n> \n> - Chris\n\nNo, this won't work. You will also rebase A^ (the o) commit in both branches\nA and B.\n\nAFAIK doing the following should do the trick:\n\ngit checkout topicB\ngit rebase --onto master A~1 topicB\n"}]}