On 16/05/16, Robert P. J. Day wrote: > > i hope rob doesn't mind my replying to his personal note from a > while back and CC'ing the list, since there's a bit more here than > meets the eye, and i wanted to make sure i was presenting it fairly. > > the problem was, having added, say, 5 linear commits to a branch (A, > B, C, D, E): > > ... X <-- A <-- B <-- C <-- D <-- E (now HEAD) > > i wanted to rebase(?) B through E on top of X as if A never happened. > > On Wed, 11 May 2016, Rob Echlin wrote: > > > This is why I think Git is the easiest way to shoot yourself in the > > foot, defined here as losing one or more of your commits. > > > > I have only done this in the GUI, but you can choose a commit and > > add the reverse of it to your current state. This means it looks > > sloppy, but I don't care, personally. So you end up with two commits > > you "didn't want", who cares? You still have that commit that > > "today" you don't want. More important, you still have all those > > other commits that you really, really want. Any commit can contain > > information that you can use in other times, other places. > > RGB suggested (as i suspected) that one can just rebase "onto", but > i didn't want to just get rid of or revert commit A. rather, in my > case, i realized only after several commits that A had been added to > the wrong branch, so i just wanted to "extract" it from where it was, > and let B through E settle back directly onto X as if A was never > there. > > putting A on a different branch was, of course, just a simple > cherry-pick. and while i haven't tested this yet, i'm assuming that i > can use a combination of cherry picking and rebasing to "extract" any > linear sequence of commits from a branch if i decide they properly > belonged elsewhere. > > is it just me, or do other people think this is a useful operation? > and is there an even simpler way to do it? No, it isn't just you, but whenever I've needed to do that, I do a cherry-pick to another branch, and rebase the one that doesn't need it. It wasn't worth trying to come up with some new command to do that when two simple tools can do it. > rday slainte mhath, RGB -- Richard Guy Briggs -- ~\ -- ~\ <hpv.tricolour.ca> <www.TriColour.ca> -- \___ o \@ @ Ride yer bike! Ottawa, ON, CANADA -- Lo_>__M__\\/\%__\\/\% Vote! -- <greenparty.ca>_____GTVS6#790__(*)__(*)________(*)(*)_________________