by shigemk2

当面は技術的なことしか書かない

直前のコミット以外のコミットメッセージを修正する方法

捻りゼロでお送り致します。
git/コミットログを修正する方法 - TOBY SOFT wiki

git rebase -i を使用する。

$ git rebase -i HEAD~3

を実行すると、

pick f7f3f6d changed my name a bit
pick 310154e updated README formatting and added blame
pick a5f4a0d added cat-file

# Rebase 710f0f8..a5f4a0d onto 710f0f8
#
# Commands:
# p, pick = use commit
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#

すると以下のようなコミットのリストが記載された内容でテキストエディタが立ち上がるので、修正したいコミットの部分の行頭のpickをedit(eでも可)に書き換え保存しエディタを終了する。