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

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

  • Subject: [OCLUG-Tech] git question: how can i drop the n'th last commit?
  • From: "Robert P. J. Day" <rpjday [ at ] crashcourse [ dot ] ca>
  • Date: Tue, 10 May 2016 06:14:21 -0400 (EDT)
  ASIDE: i know of several ways to do this, i'm just wondering if
there's a particularly elegant way i haven't thought of.

  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

then when i get my editing session with:

  pick A
  pick B
  pick C
  pick D
  pick E

i can remove the first line and save to get:

    ... X <--- B' <--- C' <--- D' <--- E' (HEAD)

is there a way to do that without having to fire up an interactive
rebase session?

  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?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================