{"thread":{"id":"26779","subject":"Q: rebasing (moving) a whole tree (not just one branch)","startedAt":"2011-03-18T20:05:30Z","lastAt":"2011-03-18T22:53:23Z","messageCount":5,"participants":["Dirk Süsserott","Jonathan Nieder","Junio C Hamano","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"163668","messageId":"4D83BB0A.8070307@dirk.my1.cc","threadId":"26779","inReplyTo":null,"subject":"Q: rebasing (moving) a whole tree (not just one branch)","fromName":"Dirk Süsserott","fromEmail":"newsletter@dirk.my1.cc","sentAt":"2011-03-18T20:05:30Z","receivedAt":"2011-03-18T20:05:30Z","isPatch":false,"sender":{"key":"newsletter@dirk.my1.cc","avatar":null},"body":"Hi,\n\nI'd like to rebase a whole tree from A to B. Not just a single branch, \nbut a whole tree. Let's say I have the following history:\n\n--- A --- B\n     |\n     + -- C -- D\n          |\n          + E -- F\n\nI'd like to rebase C and its descendants from A to B so it becomes:\n\n--- A --- B\n           |\n           + -- C' -- D'\n                |\n                + E' -- F'\n\nI know I can do it manually with\n\ngit rebase B C\ngit rebase C D\ngit rebase C E\ngit rebase E F\n\nIs there a way to just say \"rebase C and all after that from A to B\"?\n\nDirk\n"},{"id":"163670","messageId":"20110318202637.GA23255@elie","threadId":"26779","inReplyTo":"4D83BB0A.8070307@dirk.my1.cc","subject":"Re: Q: rebasing (moving) a whole tree (not just one branch)","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-03-18T20:26:37Z","receivedAt":"2011-03-18T20:26:37Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi Dirk,\n\nDirk Süsserott wrote:\n\n> I'd like to rebase a whole tree from A to B. Not just a single\n> branch, but a whole tree. Let's say I have the following history:\n>\n> --- A --- B\n>     |\n>     + -- C -- D\n>          |\n>          + E -- F\n> \n> I'd like to rebase C and its descendants from A to B\n\nI'd suggest cheating by making a merge of D and F and \"rebase -p\"-ing\nthat. :)\n\nTo say something more sensible would probably require more information\nabout the particular application, though.\n\nHope that helps,\nJonathan\n"},{"id":"163677","messageId":"7vaagsw2qb.fsf@alter.siamese.dyndns.org","threadId":"26779","inReplyTo":"20110318202637.GA23255@elie","subject":"Re: Q: rebasing (moving) a whole tree (not just one branch)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-03-18T21:14:20Z","receivedAt":"2011-03-18T21:14:20Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Dirk Süsserott wrote:\n>\n>> I'd like to rebase a whole tree from A to B. Not just a single\n>> branch, but a whole tree. Let's say I have the following history:\n>>\n>> --- A --- B\n>>     |\n>>     + -- C -- D\n>>          |\n>>          + E -- F\n>> \n>> I'd like to rebase C and its descendants from A to B\n>\n> I'd suggest cheating by making a merge of D and F and \"rebase -p\"-ing\n> that. :)\n>\n> To say something more sensible would probably require more information\n> about the particular application, though.\n\nI am not a huge fan of filter-branch, but shouldn't you be able to\nfilter-branch D and F (and no other branch) on top of B?\n"},{"id":"163680","messageId":"20110318213417.GB23407@elie","threadId":"26779","inReplyTo":"7vaagsw2qb.fsf@alter.siamese.dyndns.org","subject":"Re: Q: rebasing (moving) a whole tree (not just one branch)","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-03-18T21:34:18Z","receivedAt":"2011-03-18T21:34:18Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n>> Dirk Süsserott wrote:\n\n>>> I'd like to rebase a whole tree from A to B. Not just a single\n>>> branch, but a whole tree. Let's say I have the following history:\n>>>\n>>> --- A --- B\n>>>     |\n>>>     + -- C -- D\n>>>          |\n>>>          + E -- F\n>>> \n>>> I'd like to rebase C and its descendants from A to B\n[...]\n> I am not a huge fan of filter-branch, but shouldn't you be able to\n> filter-branch D and F (and no other branch) on top of B?\n\nYes, something like\n\n\tgit filter-branch \\\n\t\t--commit-filter '\n\t\t\tif test \"$GIT_COMMIT\" = '\"$(git rev-parse A^{commit})\"'\n\t\t\tthen\n\t\t\t\tgit rev-parse B^{commit}\n\t\t\telse\n\t\t\t\tgit_commit_non_empty_tree \"$@\"\n\t\t\tfi\n\t\t' \\\n\t\t--index-filter '\n\t\t\tif test -n \"$(git rev-list -1 \"$GIT_COMMIT\"..A)\"\n\t\t\tthen\n\t\t\t\t# descends from A\n\t\t\t\tgit merge-recursive A -- \"$GIT_COMMIT\" B\n\t\t\tfi\n\t\t' -- --all --not A^\n\nmight do it, assuming the diff from A to B is simple enough for a\nfully automatic rebase.\n\nBut in practice, something may well be much better.  It depends why we\nare performing this mass-rebasing --- do A and B have the same content\nin the moment and different histories?  How did the topics we are\nrebasing get tangled, and is their history going to remain meaningful\nafter this operation?\n\nJonathan\n"},{"id":"163692","messageId":"201103182353.24517.j6t@kdbg.org","threadId":"26779","inReplyTo":"7vaagsw2qb.fsf@alter.siamese.dyndns.org","subject":"Re: Q: rebasing (moving) a whole tree (not just one branch)","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2011-03-18T22:53:23Z","receivedAt":"2011-03-18T22:53:23Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Freitag, 18. März 2011, Junio C Hamano wrote:\n> Jonathan Nieder <jrnieder@gmail.com> writes:\n> > Dirk Süsserott wrote:\n> >> I'd like to rebase a whole tree from A to B. Not just a single\n> >> branch, but a whole tree. Let's say I have the following history:\n> >>\n> >> --- A --- B\n> >>\n> >>     + -- C -- D\n> >>\n> >>          + E -- F\n> >>\n> >> I'd like to rebase C and its descendants from A to B\n> >\n> > I'd suggest cheating by making a merge of D and F and \"rebase -p\"-ing\n> > that. :)\n> >\n> > To say something more sensible would probably require more information\n> > about the particular application, though.\n>\n> I am not a huge fan of filter-branch, but shouldn't you be able to\n> filter-branch D and F (and no other branch) on top of B?\n\nNot in a trival way. You would need a tree-filter that re-applies the change \nbetween A and B to every transcribed commit. That will work well only if \nthere are no conflicts.\n\n-- Hannes\n"}]}