LoginSignup
17
16

More than 5 years have passed since last update.

Git でコミットする変更内容を見ながらメッセージを書く

Posted at

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 をエディタに表示するスクリプトを自分で用意して使ってたので気付きませんでした……)

17
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
16