LoginSignup
0
0

More than 3 years have passed since last update.

Gitのコミット時にコメントのフォーマットを表示する

Posted at

課題

Git のコミット時のメッセージは気をつけているものの、毎回バラバラなフォーマットで入力してしまい、見直した際に確認しづらい。

対策

コミット時にフォーマットのサンプルを表示して、参考にして記述できるようにする。

サンプルとなるフォーマット

Semantic Commit Messages と言うらしい。

導入

テンプレートファイルを作成する

まずは個人的な統一を目標とするので、自分のHomeディレクトリに作成。

~/.git_comment_template
# feat: add hat wobble
# ^--^  ^------------^
# |     |
# |     +-> Summary in present tense.
# |
# +-------> Type: fix, docs, style, refactor, perf, test, build, ci, chore, or revert.
# 
# feat - A new feature
# fix - A bug fix
# docs - Documentation only changes
# style - Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
# refactor - A code change that neither fixes a bug nor adds a feature
# perf - A code change that improves performance
# test - Adding missing tests or correcting existing tests
# build - Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
# ci - Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
# chore - Other changes that don't modify src or test files
# revert - Reverts a previous commit

テンプレートの適用

全プロジェクトで使用したいので --global オプションを使用する

git config --global commit.template ~/.git_comment_template
0
0
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
0
0