LoginSignup
127
108

More than 5 years have passed since last update.

Git のコミットメッセージをテンプレート化する

Posted at

コミットテンプレート

  • git のコミットメッセージをある程度フォーマット化したい場合、コミットテンプレートを用意できる
  • プロジェクト内でコミットメッセージの書き方を統一したい場合に便利

テンプレートファイルの用意

  • 任意の場所にテンプレートファイルを用意し、git config でそのファイルをセットする
$ touch ~/.gitmessage.txt
$ git config --global commit.template ~/.gitmessage.txt
.gitmessage.txt
[ticket: #xxxx][Task/Bug] Subject line

what happened
ref : ticket link

使用例

$ git commit

[ticket: #xxxx][Task/Bug] Subject line

what happened
ref : ticket link

# 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:
#   (use "git reset HEAD <file>..." to unstage)
#
# modified:   hoge/test.txt
#
127
108
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
127
108