home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] git question: how can i drop the n'th last commit?

  • Subject: Re: [OCLUG-Tech] git question: how can i drop the n'th last commit?
  • From: Richard Guy Briggs <rgb [ at ] tricolour [ dot ] ca>
  • Date: Tue, 10 May 2016 06:59:35 -0400
On 16/05/10, Robert P. J. Day wrote:
>   SCENARIO: most recent 5 commits on a clean, linear history branch:
> 
>     ... X <--- A <--- B <--- C <--- D <--- E (HEAD)
> 
> suddenly, i wish i hadn't done A, but want to leave the more recent
> commits on that branch (rebased of course).
> 
>   pretty sure i can do an interactive rebase, as in:
> 
>   $ git rebase -i X

In fact, I've done this before and lost a merge in the process due to the
interactive option, so I think you might need to do:

	git rebase -i A~

>   oh, wait, can't i just rebase B onto X? effectively, i want to
> reproduce the work from B to E as if it originated at X; isn't that
> just a regular rebase? thoughts?

I've never done it, but I was re-reading that manpage recently and I think you
can just do:

	git rebase --onto X B E

> 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__(*)__(*)________(*)(*)_________________