git commit
に -v
(--verbose
) オプションを付けると、コミットメッセージのテンプレートに diff が追加された状態でエディタが開きます。Diff の内容を確認しながらコミットメッセージが書けます。
こんな感じで出ます:
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
# modified: file.txt
#
# ------------------------ >8 ------------------------
# Do not touch the line above.
# Everything below will be removed.
diff --git a/file.txt b/file.txt
index 257cc56..5716ca5 100644
--- a/file.txt
+++ b/file.txt
@@ -1 +1 @@
-foo
+bar
(このオプション、かなり前からあった様ですが、diff をエディタに表示するスクリプトを自分で用意して使ってたので気付きませんでした……)