{"thread":{"id":"27534","subject":"Can't get git rebase --onto to work","startedAt":"2011-06-02T10:17:41Z","lastAt":"2011-06-02T11:28:47Z","messageCount":10,"participants":["Howard Miller","Carlos Martín Nieto","Tim Guirgies","David"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"169181","messageId":"BANLkTikF7p_XsU6YJ81bq10S3nL6tBsApg@mail.gmail.com","threadId":"27534","inReplyTo":null,"subject":"Can't get git rebase --onto to work","fromName":"Howard Miller","fromEmail":"howard@e-learndesign.co.uk","sentAt":"2011-06-02T10:17:41Z","receivedAt":"2011-06-02T10:17:41Z","isPatch":false,"sender":{"key":"howard@e-learndesign.co.uk","avatar":"https://gravatar.com/avatar/ddb66c6a4a077e52b823ac5b04f33ab927cb90e2ab1eafedaeba07b1920bb99e?d=mp&s=160"},"body":"Trying to explain this as concisely as possible.\n\nI started with the following branches (names changed to protect the guilty)...\n\n* clientA\n* clientB\n\nboth have a common ancestry....\n\nI then checked out clientB created a new branch clientB_patch and did\na load of work and commits.\n\nHowever, I actually wanted all those commits to apply to clientA\nbranch instead so....\n\ngit checkout clientA\ngit checkout -b clientA_patch     (to ensure I didn't wreck original branch)\ngit rebase --onto clientA_patch clientB clientB_patch\n\nIt says \"rewinding\" head and then applies the commits I would have expected.\n\nHowever, I have now been switched to the 'clientB_patch' branch and it\nsays that it differs from its tracked remote branch by hundreds of\ncommits.\n\nclientA_patch is unchanged. It seems to have mangled clientB_patch and\ndone nothing to clientA_patch. Where did I go wrong?\n\nTIA\n"},{"id":"169182","messageId":"20110602103259.GA30081@centaur.lab.cmartin.tk","threadId":"27534","inReplyTo":"BANLkTikF7p_XsU6YJ81bq10S3nL6tBsApg@mail.gmail.com","subject":"Re: Can't get git rebase --onto to work","fromName":"Carlos Martín Nieto","fromEmail":"carlos@cmartin.tk","sentAt":"2011-06-02T10:32:59Z","receivedAt":"2011-06-02T10:32:59Z","isPatch":false,"sender":{"key":"carlos@cmartin.tk","avatar":"https://gravatar.com/avatar/956bfe8371004f2960febf266a6af789f60cdc01fbae48bb151ad4c9b532c3a2?d=mp&s=160"},"body":"On Thu, Jun 02, 2011 at 11:17:41AM +0100, Howard Miller wrote:\n> Trying to explain this as concisely as possible.\n> \n> I started with the following branches (names changed to protect the guilty)...\n> \n> * clientA\n> * clientB\n> \n> both have a common ancestry....\n> \n> I then checked out clientB created a new branch clientB_patch and did\n> a load of work and commits.\n> \n> However, I actually wanted all those commits to apply to clientA\n> branch instead so....\n> \n> git checkout clientA\n> git checkout -b clientA_patch     (to ensure I didn't wreck original branch)\n> git rebase --onto clientA_patch clientB clientB_patch\n\nThe man page for git-rebase covers this exact situation (around line\n88 in my version) . In its case, it's\n\n    git rebase --onto master next topic\n\nwhich translates to your case as\n\n    git rebase --onto clientA clientB clientB_patch\n\nCheers,\n   cmn\n-- \nCarlos Martín Nieto | http://cmartin.tk\n\n\"¿Cómo voy a decir bobadas si soy mudo?\" -- CACHAI\n"},{"id":"169184","messageId":"20110602103833.GA4709@Imperial-SSD-Overlord","threadId":"27534","inReplyTo":"BANLkTikF7p_XsU6YJ81bq10S3nL6tBsApg@mail.gmail.com","subject":"Re: Can't get git rebase --onto to work","fromName":"Tim Guirgies","fromEmail":"lt.infiltrator@gmail.com","sentAt":"2011-06-02T10:38:35Z","receivedAt":"2011-06-02T10:38:35Z","isPatch":false,"sender":{"key":"lt.infiltrator@gmail.com","avatar":null},"body":"On Thu, Jun 02, 2011 at 11:17:41AM +0100, Howard Miller wrote:\n> Trying to explain this as concisely as possible.\n> \n> I started with the following branches (names changed to protect the guilty)...\n> \n> * clientA\n> * clientB\n> \n> both have a common ancestry....\n> \n> I then checked out clientB created a new branch clientB_patch and did\n> a load of work and commits.\n> \n> However, I actually wanted all those commits to apply to clientA\n> branch instead so....\n> \n> git checkout clientA\n> git checkout -b clientA_patch     (to ensure I didn't wreck original branch)\n> git rebase --onto clientA_patch clientB clientB_patch\n> \n> It says \"rewinding\" head and then applies the commits I would have expected.\n> \n> However, I have now been switched to the 'clientB_patch' branch and it\n> says that it differs from its tracked remote branch by hundreds of\n> commits.\n> \n> clientA_patch is unchanged. It seems to have mangled clientB_patch and\n> done nothing to clientA_patch. Where did I go wrong?\n\n\"--onto clientA_patch\"\n\nPlease read that out loud.  It's meaning in git is the same as in\nEnglish.  What you did was rebase clientB_patch _onto_ clientA_patch.\nFor more information, see \"git help rebase\".\n\nWhat you should have done instead:\n\ngit checkout -b clientA_patch clientB_patch\ngit rebase -i clientA\n\nWhat that does is create and then checkout a branch called clientA_patch\nat the same commit as clientB_patch, then rebase your currently checked\nout branch (clientA_patch) on top of clientA; the \"-i\" option allows you\ndouble check what's being rebased, as otherwise it would take a whole\nlot clientB history with it.  Simply delete the lines with the commits\nyou don't want.\n\n\nTo fix what you currently have, though, you must do the following.  Take\nheed, however, as I making assumptions that the situation is unchanged\nfrom what you described above.\n\ngit checkout clientB_patch\ngit reset --hard origin/clientB_patch\n\nI'm assuming your remote is called origin, and also that whatever you\npushed last is the latest.  If not, you'll have to look at \"git reflog\"\nto see which commit to reset the branch to.\n\nNow do:\n\ngit checkout clientA_patch\ngit reset --hard clientB_patch\ngit rebase -i clientA\n\nThat should give you what you want.\n\nGood luck.\n\n\nTim\n\n-- \n() ascii ribbon campaign - against html e-mail\n/\\ www.asciiribbon.org   - against proprietary attachments\n"},{"id":"169185","messageId":"BANLkTikTi7nryTsyNV5incW3TxaOROyzMw@mail.gmail.com","threadId":"27534","inReplyTo":"20110602103259.GA30081@centaur.lab.cmartin.tk","subject":"Re: Can't get git rebase --onto to work","fromName":"Howard Miller","fromEmail":"howard@e-learndesign.co.uk","sentAt":"2011-06-02T10:38:53Z","receivedAt":"2011-06-02T10:38:53Z","isPatch":false,"sender":{"key":"howard@e-learndesign.co.uk","avatar":"https://gravatar.com/avatar/ddb66c6a4a077e52b823ac5b04f33ab927cb90e2ab1eafedaeba07b1920bb99e?d=mp&s=160"},"body":"On 2 June 2011 11:32, Carlos Martín Nieto <carlos@cmartin.tk> wrote:\n> On Thu, Jun 02, 2011 at 11:17:41AM +0100, Howard Miller wrote:\n>> Trying to explain this as concisely as possible.\n>>\n>> I started with the following branches (names changed to protect the guilty)...\n>>\n>> * clientA\n>> * clientB\n>>\n>> both have a common ancestry....\n>>\n>> I then checked out clientB created a new branch clientB_patch and did\n>> a load of work and commits.\n>>\n>> However, I actually wanted all those commits to apply to clientA\n>> branch instead so....\n>>\n>> git checkout clientA\n>> git checkout -b clientA_patch     (to ensure I didn't wreck original branch)\n>> git rebase --onto clientA_patch clientB clientB_patch\n>\n> The man page for git-rebase covers this exact situation (around line\n> 88 in my version) . In its case, it's\n>\n>    git rebase --onto master next topic\n>\n> which translates to your case as\n>\n>    git rebase --onto clientA clientB clientB_patch\n>\n\nThanks. That's what I said (except I added an extra branch onto\nClientA because I interpreted the instructions - wrongly - to say that\nClientA would change).\n\nHowever, I've just realised the bit I missed. I still need to do a\n(fast forward) merge to get my ClientA_patch branch to actually\nreflect the changes. I can't help thinking that (although the diagrams\nare perfectly correct) that a line to the effect in the manpage might\nhave saved some thinking time :)\n"},{"id":"169186","messageId":"BANLkTin92KXYO3YF1UytcesWUV-Nh_LaGg@mail.gmail.com","threadId":"27534","inReplyTo":"20110602103833.GA4709@Imperial-SSD-Overlord","subject":"Re: Can't get git rebase --onto to work","fromName":"Howard Miller","fromEmail":"howard@e-learndesign.co.uk","sentAt":"2011-06-02T10:43:19Z","receivedAt":"2011-06-02T10:43:19Z","isPatch":false,"sender":{"key":"howard@e-learndesign.co.uk","avatar":"https://gravatar.com/avatar/ddb66c6a4a077e52b823ac5b04f33ab927cb90e2ab1eafedaeba07b1920bb99e?d=mp&s=160"},"body":"On 2 June 2011 11:38, Tim Guirgies <lt.infiltrator@gmail.com> wrote:\n> On Thu, Jun 02, 2011 at 11:17:41AM +0100, Howard Miller wrote:\n>> Trying to explain this as concisely as possible.\n>>\n>> I started with the following branches (names changed to protect the guilty)...\n>>\n>> * clientA\n>> * clientB\n>>\n>> both have a common ancestry....\n>>\n>> I then checked out clientB created a new branch clientB_patch and did\n>> a load of work and commits.\n>>\n>> However, I actually wanted all those commits to apply to clientA\n>> branch instead so....\n>>\n>> git checkout clientA\n>> git checkout -b clientA_patch     (to ensure I didn't wreck original branch)\n>> git rebase --onto clientA_patch clientB clientB_patch\n>>\n>> It says \"rewinding\" head and then applies the commits I would have expected.\n>>\n>> However, I have now been switched to the 'clientB_patch' branch and it\n>> says that it differs from its tracked remote branch by hundreds of\n>> commits.\n>>\n>> clientA_patch is unchanged. It seems to have mangled clientB_patch and\n>> done nothing to clientA_patch. Where did I go wrong?\n>\n> \"--onto clientA_patch\"\n>\n> Please read that out loud.  It's meaning in git is the same as in\n> English.  What you did was rebase clientB_patch _onto_ clientA_patch.\n> For more information, see \"git help rebase\".\n>\n> What you should have done instead:\n>\n> git checkout -b clientA_patch clientB_patch\n> git rebase -i clientA\n>\n> What that does is create and then checkout a branch called clientA_patch\n> at the same commit as clientB_patch, then rebase your currently checked\n> out branch (clientA_patch) on top of clientA; the \"-i\" option allows you\n> double check what's being rebased, as otherwise it would take a whole\n> lot clientB history with it.  Simply delete the lines with the commits\n> you don't want.\n>\n>\n> To fix what you currently have, though, you must do the following.  Take\n> heed, however, as I making assumptions that the situation is unchanged\n> from what you described above.\n>\n> git checkout clientB_patch\n> git reset --hard origin/clientB_patch\n>\n> I'm assuming your remote is called origin, and also that whatever you\n> pushed last is the latest.  If not, you'll have to look at \"git reflog\"\n> to see which commit to reset the branch to.\n>\n> Now do:\n>\n> git checkout clientA_patch\n> git reset --hard clientB_patch\n> git rebase -i clientA\n>\n> That should give you what you want.\n>\n> Good luck.\n>\n>\n\nHi Tim,\n\nThanks for the lengthy post :) As I said in my previous post, I\nthink/hope I have resolved it. I did read the manpage first (I'm not\nso brave not to before posting here!!) and it did what it said it\nwould. I just misinterpreted it. A final merge was required. I\nactually picked that up from the \"Pro Git\" book page which mentions\nthat extra step.\n"},{"id":"169187","messageId":"20110602105223.GB4709@Imperial-SSD-Overlord","threadId":"27534","inReplyTo":"BANLkTin92KXYO3YF1UytcesWUV-Nh_LaGg@mail.gmail.com","subject":"Re: Can't get git rebase --onto to work","fromName":"Tim Guirgies","fromEmail":"lt.infiltrator@gmail.com","sentAt":"2011-06-02T10:52:24Z","receivedAt":"2011-06-02T10:52:24Z","isPatch":false,"sender":{"key":"lt.infiltrator@gmail.com","avatar":null},"body":"On Thu, Jun 02, 2011 at 11:43:19AM +0100, Howard Miller wrote:\n> Hi Tim,\n> \n> Thanks for the lengthy post :) As I said in my previous post, I\n> think/hope I have resolved it. I did read the manpage first (I'm not\n> so brave not to before posting here!!) and it did what it said it\n> would. I just misinterpreted it. A final merge was required. I\n> actually picked that up from the \"Pro Git\" book page which mentions\n> that extra step.\n\nWell, I'm confused, but that'll be due to my ignorance.\n\nAs long as you're sorted out.\n\n\nAs for the manpage, though, as someone who read and misunderstood it, do\nyou have any suggestions for its improvements?\n\n\nTim\n\n-- \n() ascii ribbon campaign - against html e-mail\n/\\ www.asciiribbon.org   - against proprietary attachments\n"},{"id":"169188","messageId":"BANLkTik-o=h05=d5JH_LirYQkNzgdYaZxg@mail.gmail.com","threadId":"27534","inReplyTo":"20110602105223.GB4709@Imperial-SSD-Overlord","subject":"Re: Can't get git rebase --onto to work","fromName":"Howard Miller","fromEmail":"howard@e-learndesign.co.uk","sentAt":"2011-06-02T10:58:36Z","receivedAt":"2011-06-02T10:58:36Z","isPatch":false,"sender":{"key":"howard@e-learndesign.co.uk","avatar":"https://gravatar.com/avatar/ddb66c6a4a077e52b823ac5b04f33ab927cb90e2ab1eafedaeba07b1920bb99e?d=mp&s=160"},"body":"On 2 June 2011 11:52, Tim Guirgies <lt.infiltrator@gmail.com> wrote:\n> On Thu, Jun 02, 2011 at 11:43:19AM +0100, Howard Miller wrote:\n>> Hi Tim,\n>>\n>> Thanks for the lengthy post :) As I said in my previous post, I\n>> think/hope I have resolved it. I did read the manpage first (I'm not\n>> so brave not to before posting here!!) and it did what it said it\n>> would. I just misinterpreted it. A final merge was required. I\n>> actually picked that up from the \"Pro Git\" book page which mentions\n>> that extra step.\n>\n> Well, I'm confused, but that'll be due to my ignorance.\n\nI very much doubt it :) It'll be me failing to explain properly.\n\n>\n>\n> As for the manpage, though, as someone who read and misunderstood it, do\n> you have any suggestions for its improvements?\n>\n\nThe examples are very helpful but it could be a little more explicit\nwhich branches are going to get modified by the rebase. Once there are\nseveral branches in play it becomes quite a hard think.\n\nMostly, I just needed a kick to say \"look where the branch heads are\npointing\" (in the example diagrams) before and after the rebase. I\ndon't think I would have got it without the remark in Pro Git that a\nfinal merge is required to get the HEADs where I wanted them. Like\nmost things - it's completely obvious when you know.\n"},{"id":"169189","messageId":"BANLkTi=P_-XbmeJiUs2FaEfXLksKM6jRgw@mail.gmail.com","threadId":"27534","inReplyTo":"BANLkTik-o=h05=d5JH_LirYQkNzgdYaZxg@mail.gmail.com","subject":"Re: Can't get git rebase --onto to work","fromName":"David","fromEmail":"bouncingcats@gmail.com","sentAt":"2011-06-02T11:18:06Z","receivedAt":"2011-06-02T11:18:06Z","isPatch":false,"sender":{"key":"bouncingcats@gmail.com","avatar":null},"body":"On 2 June 2011 20:58, Howard Miller <howard@e-learndesign.co.uk> wrote:\n>\n> The examples are very helpful but it could be a little more explicit\n> which branches are going to get modified by the rebase. Once there are\n> several branches in play it becomes quite a hard think.\n>\n> Mostly, I just needed a kick to say \"look where the branch heads are\n> pointing\" (in the example diagrams) before and after the rebase. I\n> don't think I would have got it without the remark in Pro Git that a\n> final merge is required to get the HEADs where I wanted them. Like\n> most things - it's completely obvious when you know.\n\nIf you have a graphical environment, it might help to take a look with\n'gitk --all'.\nAlso, if you start it before the rebase, then after the rebase you\nwill need to use its \"File>Reload\" command to refresh the display.\n"},{"id":"169190","messageId":"20110602111825.GC4709@Imperial-SSD-Overlord","threadId":"27534","inReplyTo":"BANLkTik-o=h05=d5JH_LirYQkNzgdYaZxg@mail.gmail.com","subject":"Re: Can't get git rebase --onto to work","fromName":"Tim Guirgies","fromEmail":"lt.infiltrator@gmail.com","sentAt":"2011-06-02T11:18:26Z","receivedAt":"2011-06-02T11:18:26Z","isPatch":false,"sender":{"key":"lt.infiltrator@gmail.com","avatar":null},"body":"On Thu, Jun 02, 2011 at 11:58:36AM +0100, Howard Miller wrote:\n> On 2 June 2011 11:52, Tim Guirgies <lt.infiltrator@gmail.com> wrote:\n> I very much doubt it :) It'll be me failing to explain properly.\n\nI wasn't fishing for compliments; I'm actually confused about that\nfast-forward merge.  Why do you need it?  What are you fast-forwarding\nand where to?\n\n> On 2 June 2011 11:52, Tim Guirgies <lt.infiltrator@gmail.com> wrote:\n> > As for the manpage, though, as someone who read and misunderstood it, do\n> > you have any suggestions for its improvements?\n> \n> The examples are very helpful but it could be a little more explicit\n> which branches are going to get modified by the rebase. Once there are\n> several branches in play it becomes quite a hard think.\n> \n> Mostly, I just needed a kick to say \"look where the branch heads are\n> pointing\" (in the example diagrams) before and after the rebase. I\n> don't think I would have got it without the remark in Pro Git that a\n> final merge is required to get the HEADs where I wanted them. Like\n> most things - it's completely obvious when you know.\n\nI'll try to prepare a patch and see if I can improve the wording at all.\nI'd like you to have a look over it, if you don't mind, and with your\nrecent episode fresh in your mind, review it as if you were reading it\nin that situation for the first time.\n\nCan you please also point out which section of the doc caused you\nconfusion?\n\n\nTim\n\n-- \n() ascii ribbon campaign - against html e-mail\n/\\ www.asciiribbon.org   - against proprietary attachments\n"},{"id":"169191","messageId":"BANLkTimJQPvJ2oJh9BbcoZ-1ktSdAzTm2g@mail.gmail.com","threadId":"27534","inReplyTo":"20110602111825.GC4709@Imperial-SSD-Overlord","subject":"Re: Can't get git rebase --onto to work","fromName":"Howard Miller","fromEmail":"howard@e-learndesign.co.uk","sentAt":"2011-06-02T11:28:47Z","receivedAt":"2011-06-02T11:28:47Z","isPatch":false,"sender":{"key":"howard@e-learndesign.co.uk","avatar":"https://gravatar.com/avatar/ddb66c6a4a077e52b823ac5b04f33ab927cb90e2ab1eafedaeba07b1920bb99e?d=mp&s=160"},"body":"> Can you please also point out which section of the doc caused you\n> confusion?\n>\n>\n\nOk... this is exactly my situation (and solution)\n\n\"First let’s assume your topic is based on branch next. For example, a\nfeature developed in topic depends on some functionality which is\nfound in next.\n\n    o---o---o---o---o  master\n         \\\n          o---o---o---o---o  next\n                           \\\n                            o---o---o  topic\nWe want to make topic forked from branch master; for example, because\nthe functionality on which topic depends was merged into the more\nstable master branch. We want our tree to look like this:\n\n    o---o---o---o---o  master\n        |            \\\n        |             o'--o'--o'  topic\n         \\\n          o---o---o---o---o  next\nWe can get this using the following command:\n\ngit rebase --onto master next topic\"\n\nHowever, I didn't look at the HEADs (seems stupid now). What I was\naiming for was (simply) for 'master' to have the 'topic' branch\nchanges (the delta between next and topic being applied to master if\nyou will). The only outstanding step was to checkout master and merge\ntopic (which will always bee fast-forward, of course).\n\nIt's the topic branch that gets rebased - obvious (now) but I\ninterpreted it as the master branch getting modified (--onto master\ni.e. play the changes 'onto' master and modify master).\n\nI didn't read it carefully enough - makes sense now.\n"}]}