How can I change the default comments in the git commit message?

zedoo picture zedoo · Oct 19, 2010 · Viewed 24.1k times · Source

Is it possible to modify the commented part of the default git commit message? I want to add a bit more 'context' information for my users.

# Please enter the commit message for your changes.
# (Comment lines starting with '#' will not be included)
# Explicit paths specified without -i nor -o; assuming --only paths...
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   test.txt
#

Answer

Jakub Narębski picture Jakub Narębski · Oct 19, 2010

There is commit.template configuration variable, which according to git-config(1) manpage:

Specify a file to use as the template for new commit messages. "~/" is expanded to the value of $HOME and "~user/" to the specified user's home directory.

You can put it in per-repository (.git/config), user's (~/.gitconfig) and system (/etc/gitconfig) configuration file(s).