{"thread":{"id":"27521","subject":"Created branch in wrong place... how to fix?","startedAt":"2011-06-01T12:47:12Z","lastAt":"2011-06-02T06:28:59Z","messageCount":4,"participants":["Howard Miller","Tim Guirgies","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"169111","messageId":"BANLkTingMK3Zv6NZdFAiLXZzJpSZYZmjQA@mail.gmail.com","threadId":"27521","inReplyTo":null,"subject":"Created branch in wrong place... how to fix?","fromName":"Howard Miller","fromEmail":"howard@e-learndesign.co.uk","sentAt":"2011-06-01T12:47:12Z","receivedAt":"2011-06-01T12:47:12Z","isPatch":false,"sender":{"key":"howard@e-learndesign.co.uk","avatar":"https://gravatar.com/avatar/ddb66c6a4a077e52b823ac5b04f33ab927cb90e2ab1eafedaeba07b1920bb99e?d=mp&s=160"},"body":"Hi,\nI created a branch in a project and did a series of commits. I now\ndiscover that I really wanted to make all those changes against a\ncompletely different branch of the same project. There shouldn't be\nany issues as the branch introduces entirely new files (no changes to\nexisting code).\nI'm struggling to see a way to do this without loosing the history.\nSome Google'ing suggests 'rebase --onto' but I'm struggling to see how\nthis works or if it is appropriate. Any pointers much appreciated :)\nThanks.\n"},{"id":"169112","messageId":"20110601125217.GB25353@Imperial-SSD-Overlord","threadId":"27521","inReplyTo":"BANLkTingMK3Zv6NZdFAiLXZzJpSZYZmjQA@mail.gmail.com","subject":"Re: Created branch in wrong place... how to fix?","fromName":"Tim Guirgies","fromEmail":"lt.infiltrator@gmail.com","sentAt":"2011-06-01T12:52:19Z","receivedAt":"2011-06-01T12:52:19Z","isPatch":false,"sender":{"key":"lt.infiltrator@gmail.com","avatar":null},"body":"On Wed, Jun 01, 2011 at 01:47:12PM +0100, Howard Miller wrote:\n> Hi,\n> I created a branch in a project and did a series of commits. I now\n> discover that I really wanted to make all those changes against a\n> completely different branch of the same project. There shouldn't be\n> any issues as the branch introduces entirely new files (no changes to\n> existing code).\n> I'm struggling to see a way to do this without loosing the history.\n> Some Google'ing suggests 'rebase --onto' but I'm struggling to see how\n> this works or if it is appropriate. Any pointers much appreciated :)\n> Thanks.\n\n\"git rebase\" is indeed what you want to do.  Simply put, it takes all\nyour commits and rebases them somewhere else; i.e., makes them sit on\ntop of a different commit.  See \"git help rebase\" for a more detailed\nexplanation.\n\nOf course, if you've already pushed and people have pulled from you,\nyou'll have problems; see the \"recovering from upstream rebase\" section\nin \"git help rebase\".\n\nYou'll also want to do \"git rebase -i\".  The \"-i\" option ensures that\nyou can review what commits will be rebased, and even rearange, leave\nout, or edit commits.\n\nGood luck.\n\n-- \n() ascii ribbon campaign - against html e-mail\n/\\ www.asciiribbon.org   - against proprietary attachments\n"},{"id":"169114","messageId":"m362opy8xz.fsf@localhost.localdomain","threadId":"27521","inReplyTo":"BANLkTingMK3Zv6NZdFAiLXZzJpSZYZmjQA@mail.gmail.com","subject":"Re: Created branch in wrong place... how to fix?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-06-01T13:32:24Z","receivedAt":"2011-06-01T13:32:24Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Howard Miller <howard@e-learndesign.co.uk> writes:\n\n> I created a branch in a project and did a series of commits. I now\n> discover that I really wanted to make all those changes against a\n> completely different branch of the same project. There shouldn't be\n> any issues as the branch introduces entirely new files (no changes to\n> existing code).\n>\n> I'm struggling to see a way to do this without loosing the history.\n> Some Google'ing suggests 'rebase --onto' but I'm struggling to see how\n> this works or if it is appropriate. Any pointers much appreciated :)\n> Thanks.\n\nThis is decidely work for git rebase:\n\n  $ git rebase --onto <where it should be based> <where it is based> <branch>\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"169178","messageId":"201106020829.01063.jnareb@gmail.com","threadId":"27521","inReplyTo":"BANLkTiktYkvGqc9Wq51-QMKe2kHzcmGXRQ@mail.gmail.com","subject":"Re: Created branch in wrong place... how to fix?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-06-02T06:28:59Z","receivedAt":"2011-06-02T06:28:59Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Howard Miller wrote:\n\n> > > I created a branch in a project and did a series of commits. I now\n> > > discover that I really wanted to make all those changes against a\n> > > completely different branch of the same project. There shouldn't be\n> > > any issues as the branch introduces entirely new files (no changes to\n> > > existing code).\n> > >\n> > > I'm struggling to see a way to do this without loosing the history.\n> > > Some Google'ing suggests 'rebase --onto' but I'm struggling to see how\n> > > this works or if it is appropriate. Any pointers much appreciated :)\n> > > Thanks.\n> >\n> > This is decidely work for git rebase:\n> >\n> >  $ git rebase --onto <where it should be based> <where it is based> <branch>\n>\n> Thanks.... I've re-read the rebase help and spotted the appropriate\n> example. This makes sense.\n> \n> The only thing that I'm a little bit unsure of is what does 'upstream'\n> actually mean (used in the help quite liberally)? Does it just mean an\n> older ancestor of the current HEAD? I was struggling to find a definition.\n\ngitglossary(7) has the following definition:\n\n upstream branch::\n        The default branch that is merged into the branch in question\n        (or the branch in question is rebased onto). It is configured\n        via `branch.<name>.remote` and `branch.<name>.merge`. If the\n        upstream branch of 'A' is 'origin/B' sometimes we say\n        \"'A' is tracking 'origin/B'\"\n\nBut in the case of rebase \"upstream\" means branch you forked from (you\ncreated branch from).\n\n\nN.B. if the branch in question is not too old, you can examine its\nreflog ('git log -g <branch>' or 'git reflog show <branch>') for a creation\nevent, e.g.:\n\n  2de58b3 gitweb/doc@{24}: branch: Created from origin\n-- \nJakub Narebski\nPoland\n"}]}