iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
😽

Setting a default commit message for each Git repository

に公開

git allows you to set a default commit message using commit.template.

For example, in the repository for this blog, I put 📝 :pencil: at the beginning of the commit message when I write a post.

Since it's a hassle to type every time, I'll try to streamline it using commit.template.

Step 1. Prepare a template file

In this case, we will prepare a file with just :pencil: entered.

:pencil:

Some people set up emoji conventions using comments.

# ==================== Emojis ====================
# 🎉  :tada: Initial Commit
# 🔖  :bookmark: Version Tag
# ✨  :sparkles: New Feature
...

Step 2. Configure git

The local (per-project) git config is saved in the .git/config file.

When using a command:

git config --local commit.template .commit_template

When modifying directly:

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

Discussion