😽

gitリポジトリごとにデフォルトのコミットメッセージを設定する

2021/09/18に公開

git は commit.template でデフォルトのコミットメッセージの設定できます。

例えばこのブログのリポジトリは、記事を書いたとき 📝 :pencil: をコミットメッセージの先頭に入れています。

毎回入力するのは面倒なので commit.template を使って省略してみます。

手順 1. テンプレートファイルを用意する

今回は「 :pencil:」 とだけ入力したファイルを用意します。

:pencil:

コメントを使って絵文字規約を設定している人もいます。

# ==================== Emojis ====================
# 🎉  :tada: 初めてのコミット(Initial Commit)
# 🔖  :bookmark: バージョンタグ(Version Tag)
# ✨  :sparkles: 新機能(New Feature)
...

手順 2. git 設定する

local(プロジェクトごと) の git config は .git/config ファイルに保存されます。

コマンドを使う場合、

git config --local commit.template .commit_template

直接変更する場合、

title=.git/config
[commit]
template = .commit_template
GitHubで編集を提案

Discussion