Open Source

Mastering Targeted History Rewrites with Git 2.54's New `git history` Command

2026-05-02 03:07:33

Introduction

Git 2.54, released with contributions from over 137 developers, introduces an experimental command designed for simpler history rewriting tasks: git history. Unlike the full power (and complexity) of git rebase -i, this new command focuses on two specific operations: reword and split. Whether you need to fix a typo in an old commit message or carve a large commit into two logical pieces, git history offers a targeted, non-interactive approach that doesn't touch your working tree or index. This guide walks you through everything you need to get started.

Mastering Targeted History Rewrites with Git 2.54's New `git history` Command
Source: github.blog

What You Need

Step-by-Step Guide

Step 1: Upgrade to Git 2.54

If you haven't already, install or compile Git 2.54. On macOS, use Homebrew: brew upgrade git. On Ubuntu/Debian, add the official Git PPA or build from source. Verify the version:

git --version
# Should output something like: git version 2.54.0

Step 2: Understand the Limitations

Before diving in, note that git history is experimental and intentionally limited. It does not support merge commits. It will refuse any operation that would cause a merge conflict. It's built on top of git replay's machinery, making it safe for linear histories. Always test on a backup or a separate clone first.

Step 3: Reword a Commit Message

To change the message of a specific commit (without interactive rebase), use git history reword. This opens your editor with the existing message, lets you edit it, and then rewrites history from that point forward. It does not modify your working tree or index, and it works even in bare repositories.

  1. Identify the commit hash (e.g., abc123) using git log --oneline.
  2. Run: git history reword abc123.
  3. Your default editor opens with the current message. Edit as needed, save, and close.
  4. Git automatically updates all descendant branches to point to the rewritten commit.

Example: Suppose commit a1b2c3 has the message “Fix typo” but you want “Fix critical typo in login flow”. Running the reword command lets you change it instantly.

Step 4: Split a Commit into Two

Use git history split <commit> to interactively carve out hunks into a new parent commit. The interface is similar to git add -p. After selecting which hunks belong to the new commit, Git creates a new parent commit with those changes, and the original commit retains the remaining hunks. All descendant branches are rewritten.

  1. Check the commit you want to split with git show <commit>.
  2. Run: git history split <commit> (e.g., git history split HEAD).
  3. For each hunk, you'll see a prompt like: (1/1) Stage addition [y,n,q,a,d,p,?]?. Press y to include that hunk in the new parent commit, or n to leave it in the original commit.
  4. After making your choices, Git creates the new commit and rewrites history. The original commit now has the new commit as its first parent.

Practical tip: Use this when you accidentally bundled two unrelated changes into a single commit. For example, a commit that both adds a feature and fixes a typo can be split into two clean commits.

Mastering Targeted History Rewrites with Git 2.54's New `git history` Command
Source: github.blog

Step 5: Verify the Rewritten History

After using either operation, inspect the new commit graph with git log --oneline --graph. Check that branch pointers have moved correctly. If something goes wrong, you can reset to the original state using git reflog – but note that git history does not create any backup references automatically.

Tips for Success

Conclusion

Git 2.54's git history command fills a niche gap: straightforward commit message editing and commit splitting without the overhead of interactive rebase. By leveraging the robust git replay machinery under the hood, it provides a safe, focused tool for these two operations. While it won't replace git rebase -i for complex scenarios, it's a welcome addition for everyday quick fixes. Upgrade to Git 2.54, give it a try on a test repository, and see how it simplifies your history maintenance tasks.

Explore

Microsoft Overhauls Windows 11 Run Menu: Dark Mode, New Commands in Insider Test 9to5Mac Daily April 30, 2026: OpenAI Smartphone Buzz and Top Apple News Mastering Controller Resilience: A Guide to Staleness Mitigation and Observability in Kubernetes v1.36 5 Reasons Scientists Think Venus Is Volcanically Active (and How a 2022 Eruption Helps Confirm It) Renewable Energy Surges Past Natural Gas in US: A Milestone for Clean Power