{"thread":{"id":"14662","subject":"git rebase to move a batch of patches onto the current branch","startedAt":"2008-07-24T19:57:03Z","lastAt":"2008-07-25T20:31:18Z","messageCount":9,"participants":["Avery Pennarun","Alex Riesen","Daniel Barkalow","Stephan Beyer","Björn Steinbrink"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"84784","messageId":"32541b130807241257j7820a591if8ca01c66bbcd6b2@mail.gmail.com","threadId":"14662","inReplyTo":null,"subject":"git rebase to move a batch of patches onto the current branch","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2008-07-24T19:57:03Z","receivedAt":"2008-07-24T19:57:03Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"Hi,\n\nI often find myself being on a branch and wanting to do the equivalent\nof a series of cherry-picks from another branch into the current one.\nUnfortunately, \"git cherry-pick\" only does one patch at a time (which\nis very tedious), and \"git rebase\", which is much less tedious to use,\nseems to specializing in applying your current branch on top of\nanother branch, not the other way around.\n\nCurrently I do something like this:\n\n      git checkout -b tmp branch_with_interesting_stuff~5\n      git rebase --onto mybranch branch_with_interesting_stuff~15\n      git branch -d mybranch\n      git branch -m tmp mybranch\n\nBut it seems a little complex when what I *really* want to type is\nsomething like:\n\n      git cherry-pick\nbranch_with_interesting_stuff~15..branch_with_interesting_stuff~5\n\nand have it give me a rebase-style UI in case of conflicts, etc.  And\nof course, even more bonus points if I can get \"rebase -i\"\nfunctionality.\n\nAm I missing an obvious syntax option here or is this not something\nnormal people want to do?\n\nI see that the second option to rebase sounds almost right:\n\n       If <branch> is specified, git-rebase will perform an automatic git\n       checkout <branch> before doing anything else. Otherwise it remains\n       on the current branch.\n\nSo I could perhaps do this:\n\n       git rebase --onto mybranch branch_with_interesting_stuff~15 \\\n              branch_with_interesting_stuff\n\nBut it sounds like that would rewrite branch_with_interesting_stuff\ninstead of mybranch.\n\nThanks,\n\nAvery\n"},{"id":"84788","messageId":"20080724201333.GA3760@blimp.local","threadId":"14662","inReplyTo":"32541b130807241257j7820a591if8ca01c66bbcd6b2@mail.gmail.com","subject":"Re: git rebase to move a batch of patches onto the current branch","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-07-24T20:13:33Z","receivedAt":"2008-07-24T20:13:33Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Avery Pennarun, Thu, Jul 24, 2008 21:57:03 +0200:\n> I often find myself being on a branch and wanting to do the equivalent\n> of a series of cherry-picks from another branch into the current one.\n> Unfortunately, \"git cherry-pick\" only does one patch at a time (which\n> is very tedious), and \"git rebase\", which is much less tedious to use,\n> seems to specializing in applying your current branch on top of\n> another branch, not the other way around.\n\nTry this:\n\n    $ type gcp3\n    gcp3 is a function\n    gcp3 ()\n    {\n\tgit format-patch -k --stdout --full-index \"$@\" | git am -k -3 --binary\n    }\n"},{"id":"84790","messageId":"32541b130807241316x4f85bcdfw12857be575fb3289@mail.gmail.com","threadId":"14662","inReplyTo":"20080724201333.GA3760@blimp.local","subject":"Re: git rebase to move a batch of patches onto the current branch","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2008-07-24T20:16:06Z","receivedAt":"2008-07-24T20:16:06Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On 7/24/08, Alex Riesen <raa.lkml@gmail.com> wrote:\n> Avery Pennarun, Thu, Jul 24, 2008 21:57:03 +0200:\n>\n> > I often find myself being on a branch and wanting to do the equivalent\n>  > of a series of cherry-picks from another branch into the current one.\n>  > Unfortunately, \"git cherry-pick\" only does one patch at a time (which\n>  > is very tedious), and \"git rebase\", which is much less tedious to use,\n>  > seems to specializing in applying your current branch on top of\n>  > another branch, not the other way around.\n>\n> Try this:\n>\n>     $ type gcp3\n>     gcp3 is a function\n>     gcp3 ()\n>     {\n>         git format-patch -k --stdout --full-index \"$@\" | git am -k -3 --binary\n>     }\n\nBut that'll give up when there are conflicts, right?  git-rebase lets\nme fix them in a nice way.\n\nAvery\n"},{"id":"84792","messageId":"20080724203049.GC3760@blimp.local","threadId":"14662","inReplyTo":"32541b130807241316x4f85bcdfw12857be575fb3289@mail.gmail.com","subject":"Re: git rebase to move a batch of patches onto the current branch","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-07-24T20:30:49Z","receivedAt":"2008-07-24T20:30:49Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Avery Pennarun, Thu, Jul 24, 2008 22:16:06 +0200:\n> On 7/24/08, Alex Riesen <raa.lkml@gmail.com> wrote:\n> >     gcp3 ()\n> >     {\n> >         git format-patch -k --stdout --full-index \"$@\" | git am -k -3 --binary\n> >     }\n> \n> But that'll give up when there are conflicts, right?  git-rebase lets\n> me fix them in a nice way.\n> \n\nNo, it same as in rebase. You'll fix them and do \"git am --resolved\".\nSee manpage of git am.\n"},{"id":"84794","messageId":"32541b130807241342h483169d7we955512879075161@mail.gmail.com","threadId":"14662","inReplyTo":"20080724203049.GC3760@blimp.local","subject":"Re: git rebase to move a batch of patches onto the current branch","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2008-07-24T20:42:58Z","receivedAt":"2008-07-24T20:42:58Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On 7/24/08, Alex Riesen <raa.lkml@gmail.com> wrote:\n> Avery Pennarun, Thu, Jul 24, 2008 22:16:06 +0200:\n> > On 7/24/08, Alex Riesen <raa.lkml@gmail.com> wrote:\n>\n> > >     gcp3 ()\n>  > >     {\n>  > >         git format-patch -k --stdout --full-index \"$@\" | git am -k -3 --binary\n>  > >     }\n>  >\n>  > But that'll give up when there are conflicts, right?  git-rebase lets\n>  > me fix them in a nice way.\n>\n> No, it same as in rebase. You'll fix them and do \"git am --resolved\".\n>  See manpage of git am.\n\nHmm, cool.\n\nSo that command isn't too easy to come upon by accident.  If I wanted\nto submit a patch to make this process a bit more obvious, would it\nmake sense to simply have git-cherry-pick call that sequence when you\ngive it more than one commit?\n\nHmm, I suppose not, since git-am is a shellscript and cherry-pick is\ncurrently a builtin, so it would be kind of a step backwards.\n\nThanks,\n\nAvery\n"},{"id":"84923","messageId":"alpine.LNX.1.00.0807251509390.19665@iabervon.org","threadId":"14662","inReplyTo":"32541b130807241342h483169d7we955512879075161@mail.gmail.com","subject":"Re: git rebase to move a batch of patches onto the current branch","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-07-25T19:16:11Z","receivedAt":"2008-07-25T19:16:11Z","isPatch":false,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Thu, 24 Jul 2008, Avery Pennarun wrote:\n\n> On 7/24/08, Alex Riesen <raa.lkml@gmail.com> wrote:\n> > Avery Pennarun, Thu, Jul 24, 2008 22:16:06 +0200:\n> > > On 7/24/08, Alex Riesen <raa.lkml@gmail.com> wrote:\n> >\n> > > >     gcp3 ()\n> >  > >     {\n> >  > >         git format-patch -k --stdout --full-index \"$@\" | git am -k -3 --binary\n> >  > >     }\n> >  >\n> >  > But that'll give up when there are conflicts, right?  git-rebase lets\n> >  > me fix them in a nice way.\n> >\n> > No, it same as in rebase. You'll fix them and do \"git am --resolved\".\n> >  See manpage of git am.\n> \n> Hmm, cool.\n> \n> So that command isn't too easy to come upon by accident.  If I wanted\n> to submit a patch to make this process a bit more obvious, would it\n> make sense to simply have git-cherry-pick call that sequence when you\n> give it more than one commit?\n\nBefore terribly long, we'll have \"git sequencer\", which should be easy to \nget to do the \"rebase -i\" thing with cherry-pick-style usage (somebody \nwould just need to write code to generate the correct series of pick \nstatements).\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"84926","messageId":"20080725192500.GB13539@leksak.fem-net","threadId":"14662","inReplyTo":"alpine.LNX.1.00.0807251509390.19665@iabervon.org","subject":"Re: git rebase to move a batch of patches onto the current branch","fromName":"Stephan Beyer","fromEmail":"s-beyer@gmx.net","sentAt":"2008-07-25T19:25:00Z","receivedAt":"2008-07-25T19:25:00Z","isPatch":false,"sender":{"key":"s-beyer@gmx.net","avatar":"https://avatars.githubusercontent.com/u/143889?v=4"},"body":"Hi,\n\nDaniel Barkalow wrote:\n> > On 7/24/08, Alex Riesen <raa.lkml@gmail.com> wrote:\n> > > Avery Pennarun, Thu, Jul 24, 2008 22:16:06 +0200:\n> > > > On 7/24/08, Alex Riesen <raa.lkml@gmail.com> wrote:\n> > >\n> > > > >     gcp3 ()\n> > >  > >     {\n> > >  > >         git format-patch -k --stdout --full-index \"$@\" | git am -k -3 --binary\n> > >  > >     }\n> > >  >\n> > >  > But that'll give up when there are conflicts, right?  git-rebase lets\n> > >  > me fix them in a nice way.\n> > >\n> > > No, it same as in rebase. You'll fix them and do \"git am --resolved\".\n> > >  See manpage of git am.\n> > \n> > Hmm, cool.\n> > \n> > So that command isn't too easy to come upon by accident.  If I wanted\n> > to submit a patch to make this process a bit more obvious, would it\n> > make sense to simply have git-cherry-pick call that sequence when you\n> > give it more than one commit?\n> \n> Before terribly long, we'll have \"git sequencer\", which should be easy to \n> get to do the \"rebase -i\" thing with cherry-pick-style usage (somebody \n> would just need to write code to generate the correct series of pick \n> statements).\n\nFor simple cases this code could be something like:\ngit rev-list --reverse --cherry-pick --no-merges --first-parent <from>..<to> |\n\tsed 's/^/pick /' | git sequencer\n\n(At least this is what I use relatively often.)\n\nBut as long as git sequencer is not in official git, this is not an\noption. :)\n\nRegards,\n  Stephan\n\n-- \nStephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F\n"},{"id":"84941","messageId":"20080725200049.GA6611@blimp.local","threadId":"14662","inReplyTo":"20080725192500.GB13539@leksak.fem-net","subject":"Re: git rebase to move a batch of patches onto the current branch","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-07-25T20:00:49Z","receivedAt":"2008-07-25T20:00:49Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Stephan Beyer, Fri, Jul 25, 2008 21:25:00 +0200:\n> Daniel Barkalow wrote:\n> > > On 7/24/08, Alex Riesen <raa.lkml@gmail.com> wrote:\n> > > > Avery Pennarun, Thu, Jul 24, 2008 22:16:06 +0200:\n> > > > > On 7/24/08, Alex Riesen <raa.lkml@gmail.com> wrote:\n> > > >\n> > > > > >     gcp3 ()\n> > > >  > >     {\n> > > >  > >         git format-patch -k --stdout --full-index \"$@\" | git am -k -3 --binary\n> > > >  > >     }\n> > > >  >\n> > > >  > But that'll give up when there are conflicts, right?  git-rebase lets\n> > > >  > me fix them in a nice way.\n> > > >\n> > > > No, it same as in rebase. You'll fix them and do \"git am --resolved\".\n> > > >  See manpage of git am.\n> > > \n> > > Hmm, cool.\n> > > \n> > > So that command isn't too easy to come upon by accident.  If I wanted\n> > > to submit a patch to make this process a bit more obvious, would it\n> > > make sense to simply have git-cherry-pick call that sequence when you\n> > > give it more than one commit?\n> > \n> > Before terribly long, we'll have \"git sequencer\", which should be easy to \n> > get to do the \"rebase -i\" thing with cherry-pick-style usage (somebody \n> > would just need to write code to generate the correct series of pick \n> > statements).\n> \n> For simple cases this code could be something like:\n> git rev-list --reverse --cherry-pick --no-merges --first-parent <from>..<to> |\n> \tsed 's/^/pick /' | git sequencer\n> \n> (At least this is what I use relatively often.)\n> \n> But as long as git sequencer is not in official git, this is not an\n> option. :)\n\nBesides, that's longer than format-patch + am for the same from..to\nrange.\n"},{"id":"84943","messageId":"20080725203118.GA28937@atjola.homenet","threadId":"14662","inReplyTo":"32541b130807241257j7820a591if8ca01c66bbcd6b2@mail.gmail.com","subject":"Re: git rebase to move a batch of patches onto the current branch","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-07-25T20:31:18Z","receivedAt":"2008-07-25T20:31:18Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.07.24 15:57:03 -0400, Avery Pennarun wrote:\n> Hi,\n> \n> I often find myself being on a branch and wanting to do the equivalent\n> of a series of cherry-picks from another branch into the current one.\n> Unfortunately, \"git cherry-pick\" only does one patch at a time (which\n> is very tedious), and \"git rebase\", which is much less tedious to use,\n> seems to specializing in applying your current branch on top of\n> another branch, not the other way around.\n> \n> Currently I do something like this:\n> \n>       git checkout -b tmp branch_with_interesting_stuff~5\n>       git rebase --onto mybranch branch_with_interesting_stuff~15\n>       git branch -d mybranch\n>       git branch -m tmp mybranch\n> \n> But it seems a little complex when what I *really* want to type is\n> something like:\n> \n>       git cherry-pick\n> branch_with_interesting_stuff~15..branch_with_interesting_stuff~5\n> \n> and have it give me a rebase-style UI in case of conflicts, etc.  And\n> of course, even more bonus points if I can get \"rebase -i\"\n> functionality.\n\nFor \"rebase -i\", this should do:\n\ngit checkout mybranch\ngit reset --hard interesting_stuff~5\ngit rebase -i --onto ORIG_HEAD interesting_stuff~5\n\nNot as nice as the format-patch thing but at least it doesn't drop your\nbraches' reflog like your version, and it provides \"rebase -i\"\nfunctionality.\n\nNote that the ORIG_HEAD thing might require a recent git version, IIRC\nthere were some patches to make rebase correctly handle that.\n\nBjörn\n"}]}