{"thread":{"id":"22503","subject":"How to rebase and rename?","startedAt":"2010-02-03T09:05:10Z","lastAt":"2010-02-03T09:48:06Z","messageCount":2,"participants":["Peter Krefting","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"133452","messageId":"alpine.DEB.2.00.1002030958380.17444@ds9.cixit.se","threadId":"22503","inReplyTo":null,"subject":"How to rebase and rename?","fromName":"Peter Krefting","fromEmail":"peter@softwolves.pp.se","sentAt":"2010-02-03T09:05:10Z","receivedAt":"2010-02-03T09:05:10Z","isPatch":false,"sender":{"key":"peter@softwolves.pp.se","avatar":"https://avatars.githubusercontent.com/u/990764?v=4"},"body":"Hi!\n\nIf I have a repository with a topic branch that is published, and that I \nwant to rebase and republish under a new name, is there an easy way of doing \nthat?\n\nI.e., I want to go from\n\n      ---C---D topic-1\n     /\n  --A---X---X---B master\n\nto\n\n        ---C---D topic-1\n \t  /\n      /           ---C'---D' topic-2\n     /           /\n  --A---X---X---B master\n\nCurrently, I do something along the lines of:\n\n  git branch topic-2 topic-1\n  git rebase master topic-2\n\nbut that feels wrong as it creates the \"topic-2\" branch pointing the \nthe wrong way first. Is there a way to eliminate that step?\n\n-- \n\\\\// Peter - http://www.softwolves.pp.se/\n"},{"id":"133457","messageId":"20100203094806.GB23956@coredump.intra.peff.net","threadId":"22503","inReplyTo":"alpine.DEB.2.00.1002030958380.17444@ds9.cixit.se","subject":"Re: How to rebase and rename?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-02-03T09:48:06Z","receivedAt":"2010-02-03T09:48:06Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Feb 03, 2010 at 10:05:10AM +0100, Peter Krefting wrote:\n\n> If I have a repository with a topic branch that is published, and\n> that I want to rebase and republish under a new name, is there an\n> easy way of doing that?\n> [...]\n> Currently, I do something along the lines of:\n> \n>  git branch topic-2 topic-1\n>  git rebase master topic-2\n> \n> but that feels wrong as it creates the \"topic-2\" branch pointing the\n> the wrong way first. Is there a way to eliminate that step?\n\nNo, I think that is the best way to do it. Since the creation of topic-2\nis happening in your (presumably) private repo, it is not a big deal for\nit to exist in an unintertesting state for a few seconds.\n\nIf you really cared, you could do the work on a detached HEAD and then\nassign the result to a new branch, but that is even more typing:\n\n  git checkout topic-1^0\n  git rebase master\n  git checkout -b topic-2\n\nIt also causes git to do slightly more work. In your example, the branch\ncreation is O(1), then rebase resets back to master and applies each\ncommit in topic-1 in turn. In mine, we actually reset the checkout to\ntopic-1, then reset it to master, and then apply the commits. Not that\nit probably matters unless you have some enormous repository.\n\n-Peff\n"}]}