When rewriting history via git-rebase(1) there are a few very common use
cases:
- The ordering of two commits should be reversed.
- A commit should be split up into two commits.
- A commit should be dropped from the history completely.
- Multiple commits should be squashed into one.
- Editing an existing commit that is not the tip of the current
branch.
While these operations are all doable, it often feels needlessly kludgey
to do so by doing an interactive rebase, using the editor to say what
one wants, and then perform the actions. Also, some operations like
splitting up a commit into two are way more involved than that and
require a whole series of commands.
Rebases also do not update dependent branches. The use of stacked
branches has grown quite common with competing version control systems
like Jujutsu though, so it clearly is a need that users have. While
rebases _can_ serve this use case if one always works on the latest
stacked branch, it is somewhat awkward and very easy to get wrong.
Add a new "history" command to plug these gaps. This command will have
several different subcommands to imperatively rewrite history for common
use cases like the above.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committedJan 13, 2026 at 10:54 UTCa675183d483cb106c076395936cd9e602ae94404
new file mode 100644index 0000000000..68c35f36b9--- /dev/null+++ b/Documentation/git-history.adoc@@ -0,0 +1,57 @@+git-history(1)+==============++NAME+----+git-history - EXPERIMENTAL: Rewrite history++SYNOPSIS+--------+[synopsis]+git history [<options>]++DESCRIPTION+-----------++Rewrite history by rearranging or modifying specific commits in the+history.++THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.++This command is related to linkgit:git-rebase[1] in that both commands can be+used to rewrite history. There are a couple of major differences though:++* linkgit:git-history[1] can work in a bare repository as it does not need to+ touch either the index or the worktree.+* linkgit:git-history[1] does not execute any linkgit:githooks[5] at the+ current point in time. This may change in the future.+* linkgit:git-history[1] by default updates all branches that are descendants+ of the original commit to point to the rewritten commit.++Overall, linkgit:git-history[1] aims to provide a more opinionated way to modify+your commit history that is simpler to use compared to linkgit:git-rebase[1] in+general.++Use linkgit:git-rebase[1] if you want to reapply a range of commits onto a+different base, or interactive rebases if you want to edit a range of commits+at once.++LIMITATIONS+-----------++This command does not (yet) work with histories that contain merges. You+should use linkgit:git-rebase[1] with the `--rebase-merges` flag instead.++Furthermore, the command does not support operations that can result in merge+conflicts. This limitation is by design as history rewrites are not intended to+be stateful operations. The limitation can be lifted once (if) Git learns about+first-class conflicts.++COMMANDS+--------++No commands are supported yet.++GIT+---+Part of the linkgit:git[1] suite