git 2.54.0ではgit historyでコミットメッセージの修正が簡単にできるぞ!!
git 2.54.0ではgit historyでコミットメッセージの修正が簡単にできるぞ!!
はじめに

2026/04/20 に git v2.54.0 がリリースされました。新しく追加されたhistoryサブコマンドを使ってみましたが、便利だったので紹介します。
$ git -v
git version 2.54.0git historyについて
マージコミットを挟まない、コミットメッセージの変更やコミットの分割といった簡単な作業をするために特化したコマンドだそうです。
提供されているのはコミットメッセージを変更するためのrewordとsplitのみで非常にコンパクトなコマンドです。
$git history -h
usage: git history reword <commit> [--dry-run] [--update-refs=(branches|head)]
or: git history split <commit> [--dry-run] [--update-refs=(branches|head)] [--] [<pathspec>...]実践
reword編
7c0bd10を「書いた2」にしたい場合、

# 1. git historyを実行
$git history reword 7c0bd10
# 2. 書いた2に変更
# 3. 結果を確認
$git log --onelineこのあとはrebaseと同じくgit push --force-with-leaseなどを実行してください。
rebase -i実行後の、pickを別のワードに書き換える手間が省けていいですね。
split編
赤枠のコミットを分割する場合、

$git history split ae6482dコマンドを実行すると、git add -pのようなUiが表われて、hunk毎に分割するか聞かれるのでy/nで返答します。
※diffの表示は恐らくdeltaの影響をうけてます

hunkの選択後、2度コミットメッセージの変更を促されて、先ほどのコミットが「分割!分割!!!!」と「feat(blog): show draft posts in dev mode with visual indicator」の2つに分割されました。

注意
This command is still marked as experimental, so its interface may evolve. Give it a try with
git history rewordandgit history split, available in Git 2.54.
実験的機能でインターフェースが変更される可能性があるそうなので、利用する際にはヘルプを確認しましょう。
There are a couple of intentional limitations worth noting. The history command does not support histories that contain merge commits, and it will refuse to perform any operation that would result in a merge conflict. By design,
git historyis meant for targeted, non-interactive rewrites, not the kind of open-ended history rewriting typically relegated togit rebase –i.
マージコミットを含む履歴には対応しておらず、マージコンフリクトが発生する可能性のある操作は実行できないようです。そういった場合は今迄どおり、rebaseの--rebase-mergeフラグなどを使う必要がありそうです。
おわりに
gitのコマンドを覚えられない自分でも使えそうな気がしてきました。これはいいぞ。