commitを綺麗にするのにgit commit --fixupとgit rebase --autosquashが便利というエントリを以前に書きました。
一方で、commitを整理するというユースケースにおいて一番使っているのはgit commit --amendです。
このブログを書く時なんかはほぼこちらしか使っていない。
git commit --amendで面倒なのは、逐一エディタが立ち上がることです。
コミットメッセージは変えたくなく、ただコミットをやり直したいだけなのに、都度エディタが開く。
エディタが開く時間を待つのは大変に面倒ですね。時間の浪費でしかない。
ちょっと調べたらすぐ解決策を見つけました。git commit --amend --no-editでできる。
$ git help commit | perl -nle 'print if /--no-edit/ ... /^\s*$/'
--no-edit
Use the selected commit message without launching an editor. For
example, git commit --amend --no-edit amends a commit without
changing its commit message.
個人的には大変ライフチェンジングでした。ぜひどうぞ。