]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/history: implement "drop" subcommand
authorPatrick Steinhardt <ps@pks.im>
Wed, 1 Jul 2026 11:35:38 +0000 (13:35 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 3 Jul 2026 17:32:47 +0000 (10:32 -0700)
commitd11b348f7840c7ae4aba5d273ff56c813475a88e
tree1d42dbcbdce3f4d7f91875974454ed27ad259ec0
parent46affdb8c74759697e9afef2a55854d3641953e1
builtin/history: implement "drop" subcommand

A common operation when editing the commit history is to drop a specific
commit from the history entirely, but this operation is not currently
covered by git-history(1).

A couple of noteworthy bits:

  - This is the first git-history(1) command that will ultimately result
    in changes to both the index and the working tree. We thus have to
    add logic to merge resulting changes into those.

  - It is still not possible to replay merge commits, so this limitation
    is inherited for the new "drop" command.

  - For now we refuse to drop root commits. While we _can_ indeed drop
    root commits in the general case, there are edge cases where the
    resulting history would become completely empty. This is thus left
    to a subsequent patch series.

Other than that, most of the logic is rather straight-forward as we can
continue to build on the preexisting logic in git-history(1) for most of
the part.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-history.adoc
builtin/history.c
t/meson.build
t/t3454-history-drop.sh [new file with mode: 0755]