Git4 択難易度 基礎

レビューで「何を直したか分からない」と言われた。伝わる書き方は?

git commit -m "fixed"

正答

  1. git commit -m "fixed some bugs and stuff"
  2. git commit -m "update cart files 2026-10-16"
  3. git commit -m "Fix crash when cart is empty"
  4. git commit -m "Fix bug reported by reviewer"

解説

コミットメッセージの 1 行目(件名)は git log --oneline や PR 一覧に出る要約で、「何をどう変えたか」が読めることが重要。Fix crash when cart is empty なら対象と症状が分かる。fixed some bugs and stuff は何を直したか不明、日付入りの update は Git が記録する情報の重複で中身が無く、reported by reviewer は経緯だけで変更内容が読めない。慣習として件名は 50 文字程度、動詞の原形で始め、詳しい背景は空行を挟んで本文に書く。

参考: git-scm.com

commitcommit-message

この問題を含む Git のテストを制限時間つきで解く

Gitクイズへ