{"thread":{"id":"44503","subject":"Rebasing cascading topic trees","startedAt":"2016-11-16T23:39:46Z","lastAt":"2016-11-17T03:21:45Z","messageCount":5,"participants":["Norbert Kiesel","Junio C Hamano","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"306088","messageId":"CAM+g_Nsiu_qqapB+FvwJCBfwEYLTPdHg4DueQWHq4XDNXMCgpQ@mail.gmail.com","threadId":"44503","inReplyTo":null,"subject":"Rebasing cascading topic trees","fromName":"Norbert Kiesel","fromEmail":"nkiesel@gmail.com","sentAt":"2016-11-16T23:39:40Z","receivedAt":"2016-11-16T23:39:46Z","isPatch":false,"sender":{"key":"nkiesel@gmail.com","avatar":null},"body":"I currently have a situation with cascading topic branches that I need to rebase\nregularly.  In the picture below, I want to rebase the tree starting with `E` to\nbe rebased onto master (my actually cascade is 4 branches deep).\n\nA--B--C--D (master)\n   \\\n    E--F (topic1)\n       \\\n        G--H (topic2)\n\nAfter running `git rebase --onto master master topic1`, I end up with\n\nA--B--C--D (master)\n   |     \\\n   \\      E'--F' (topic1)\n    E--F\n       \\\n        G--H (topic2)\n\nI then need to also run `git rebase --onto topic1 F topic2` to arrive at the\ndesired\n\nA--B--C--D (master)\n   |     \\\n   \\      E'--F' (topic1)\n    E--F      \\\n       |       G'--H' (topic2)\n       \\\n        G--H\n\nProblem here is that I don't have a nice symbolic name for `F` anymore after the\nfirst rebase. Rebasing `topic2` first is not really possible, because I do not\nhave a new graft-point yet.  I currently write down `F` ahead of time (or use\n`reflog` if I forgot) `F`, but I wonder if there is a better solution.\n"},{"id":"306089","messageId":"xmqq7f83ouqs.fsf@gitster.mtv.corp.google.com","threadId":"44503","inReplyTo":"CAM+g_Nsiu_qqapB+FvwJCBfwEYLTPdHg4DueQWHq4XDNXMCgpQ@mail.gmail.com","subject":"Re: Rebasing cascading topic trees","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-11-16T23:44:27Z","receivedAt":"2016-11-16T23:44:35Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Norbert Kiesel <nkiesel@gmail.com> writes:\n\n> I currently have a situation with cascading topic branches that I need to rebase\n> regularly.  In the picture below, I want to rebase the tree starting with `E` to\n> be rebased onto master (my actually cascade is 4 branches deep).\n>\n> A--B--C--D (master)\n>    \\\n>     E--F (topic1)\n>        \\\n>         G--H (topic2)\n>\n> After running `git rebase --onto master master topic1`, I end up with\n>\n> A--B--C--D (master)\n>    |     \\\n>    \\      E'--F' (topic1)\n>     E--F\n>        \\\n>         G--H (topic2)\n>\n> I then need to also run `git rebase --onto topic1 F topic2` to arrive at the\n> desired\n>\n> A--B--C--D (master)\n>    |     \\\n>    \\      E'--F' (topic1)\n>     E--F      \\\n>        |       G'--H' (topic2)\n>        \\\n>         G--H\n>\n> Problem here is that I don't have a nice symbolic name for `F` anymore after the\n> first rebase. Rebasing `topic2` first is not really possible, because I do not\n> have a new graft-point yet.  I currently write down `F` ahead of time (or use\n> `reflog` if I forgot) `F`, but I wonder if there is a better solution.\n\nDoesn't topic1@{1} point at \"F\" after the rebase of the topic1\nfinishes?\n\n"},{"id":"306092","messageId":"CAM+g_Ns-9Sj5r0V2XXZfGQz+0XiO1O-hT03japEGibkNgh8a4A@mail.gmail.com","threadId":"44503","inReplyTo":"xmqq7f83ouqs.fsf@gitster.mtv.corp.google.com","subject":"Re: Rebasing cascading topic trees","fromName":"Norbert Kiesel","fromEmail":"nkiesel@gmail.com","sentAt":"2016-11-17T00:12:20Z","receivedAt":"2016-11-17T00:12:28Z","isPatch":false,"sender":{"key":"nkiesel@gmail.com","avatar":null},"body":"Yes, `git rebase --onto topic1 topic1@{1} topic2` is the answer!\n\nThanks so much, learned something new today.\n\nOn Wed, Nov 16, 2016 at 3:44 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Norbert Kiesel <nkiesel@gmail.com> writes:\n>\n>> I currently have a situation with cascading topic branches that I need to rebase\n>> regularly.  In the picture below, I want to rebase the tree starting with `E` to\n>> be rebased onto master (my actually cascade is 4 branches deep).\n>>\n>> A--B--C--D (master)\n>>    \\\n>>     E--F (topic1)\n>>        \\\n>>         G--H (topic2)\n>>\n>> After running `git rebase --onto master master topic1`, I end up with\n>>\n>> A--B--C--D (master)\n>>    |     \\\n>>    \\      E'--F' (topic1)\n>>     E--F\n>>        \\\n>>         G--H (topic2)\n>>\n>> I then need to also run `git rebase --onto topic1 F topic2` to arrive at the\n>> desired\n>>\n>> A--B--C--D (master)\n>>    |     \\\n>>    \\      E'--F' (topic1)\n>>     E--F      \\\n>>        |       G'--H' (topic2)\n>>        \\\n>>         G--H\n>>\n>> Problem here is that I don't have a nice symbolic name for `F` anymore after the\n>> first rebase. Rebasing `topic2` first is not really possible, because I do not\n>> have a new graft-point yet.  I currently write down `F` ahead of time (or use\n>> `reflog` if I forgot) `F`, but I wonder if there is a better solution.\n>\n> Doesn't topic1@{1} point at \"F\" after the rebase of the topic1\n> finishes?\n>\n"},{"id":"306096","messageId":"20161117014522.lzk43sfmpl4ted3d@sigill.intra.peff.net","threadId":"44503","inReplyTo":"CAM+g_Ns-9Sj5r0V2XXZfGQz+0XiO1O-hT03japEGibkNgh8a4A@mail.gmail.com","subject":"Re: Rebasing cascading topic trees","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-11-17T01:45:22Z","receivedAt":"2016-11-17T01:45:29Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Nov 16, 2016 at 04:12:20PM -0800, Norbert Kiesel wrote:\n\n> Yes, `git rebase --onto topic1 topic1@{1} topic2` is the answer!\n\nSee also the `--fork-point` option, which (I think) should do this for\nyou (and is the default if \"topic1\" is the configured upstream for\ntopic2 and you just run \"git rebase\").\n\n-Peff\n"},{"id":"306097","messageId":"CAM+g_Ns8bxry2j0X5=1k+WwQ0ZbHP=19jHRsDovC6GFGvYtBCQ@mail.gmail.com","threadId":"44503","inReplyTo":"20161117014522.lzk43sfmpl4ted3d@sigill.intra.peff.net","subject":"Re: Rebasing cascading topic trees","fromName":"Norbert Kiesel","fromEmail":"nkiesel@gmail.com","sentAt":"2016-11-17T03:21:19Z","receivedAt":"2016-11-17T03:21:45Z","isPatch":false,"sender":{"key":"nkiesel@gmail.com","avatar":null},"body":"More things I learned!\n\nSo there are (at least) 2 possible approaches: using history, or using\nlocal tracking branches.  The latter looks actually nicer to me, with\nthe exception that if asks for a `git pull`.  Using `git pull\n--rebase` actually also ends up with the same tree, but I like the\nrebase better.\n\nThe following 2 scripts show the 2 approaches.  Only difference is in\nthe creation of topic/b and the last rebase command.\n\n# History\nmkdir topic; cd topic\ngit init\ndate > a; git add a; git commit -m a\ndate > b; git add b; git commit -m b\ngit branch -b topic/a\ngit checkout -b topic1\ndate > c; git add c; git commit -m c\ndate > d; git add d; git commit -m d\ngit checkout -b topic2\ndate > e; git add e; git commit -m e\ndate > f; git add f; git commit -m f\ngit checkout master\ndate > g; git add g; git commit -m g\necho \"before rebase\"; git log --oneline --graph --all\ngit rebase master topic1\necho \"after rebase of topic1\"; git log --oneline --graph --all\ngit rebase --onto=topic1 topic1@{1} topic2\necho \"after rebase of topic2\"; git log --oneline --graph --all\n\n# Tracking\nmkdir topic; cd topic\ngit init\ndate > a; git add a; git commit -m a\ndate > b; git add b; git commit -m b\ngit branch -b topic/a\ngit checkout -b topic1\ndate > c; git add c; git commit -m c\ndate > d; git add d; git commit -m d\ngit checkout --track topic1 -b topic2\ndate > e; git add e; git commit -m e\ndate > f; git add f; git commit -m f\ngit checkout master\ndate > g; git add g; git commit -m g\necho \"before rebase\"; git log --oneline --graph --all\ngit rebase master topic1\necho \"after rebase of topic1\"; git log --oneline --graph --all\ngit rebase --onto=topic1 master topic2\necho \"after rebase of topic2\"; git log --oneline --graph --all\n\nOn Wed, Nov 16, 2016 at 5:45 PM, Jeff King <peff@peff.net> wrote:\n> On Wed, Nov 16, 2016 at 04:12:20PM -0800, Norbert Kiesel wrote:\n>\n>> Yes, `git rebase --onto topic1 topic1@{1} topic2` is the answer!\n>\n> See also the `--fork-point` option, which (I think) should do this for\n> you (and is the default if \"topic1\" is the configured upstream for\n> topic2 and you just run \"git rebase\").\n>\n> -Peff\n"}]}