Below is a simple script that rewrites history reverting a single commit.
This differs from git-revert in that a commit is completely removed,
and is especially useful before one has published a series of
Do you find this useful? Comments?
Drop me a line.
revlist=`git-rev-list $commit.. | tac`
git reset --hard $commit
git reset --hard HEAD~1
for rev in $revlist
That may be well when no patch depends on the one you kill. In that
case, it surely requires some work to handfix things.
I'd suggest to use stgit to prepare commits before publication. Even
if you don't feel the need for it in everyday life, you can have a
one-shot use for this particular problem, by turning your latest
commits into an stgit stack, use stgit facilities to handle posible
conflicts, and turn them into commits again:
The nominal case goes:
stg uncommit -n <ncommits>
stg float <patch-to-kill>
stg delete <patch-to-kill>
And if there is any conflict, you can still solve them, decide to
change your plans, get diffs from gitk, etc.
"Do you find this useful" is a loaded question.
I do it all the time with git-rebase, so the need to remove a
botched commit from the history and rebuild the remainder is
certainly there, meaning "what your patch does IS useful".
I do it all the time with git-rebase, so I personally do not
need a new tool to do this, meaning "your patch is not useful to
When I find master~8 and master~9 to be undesirable, I would do:
$ git rebase --onto master~10 master~8
which rebuilds master~7 and onward on top of master~10, thereby
dropping two commits.