Git Reference ยท Configuration Options
commit.* settings
Reference for commit.* settings: commit.template, commit.gpgSign, commit.verbose, commit.cleanup, commit.status and commit.signoff, with runnable examples.
The commit.* settings control git commit: what the message editor starts with (commit.template), what is shown while you write (commit.verbose, commit.status), how the message is cleaned up afterwards (commit.cleanup) and whether commits are signed automatically (commit.gpgSign).
They also apply to commands that create commits through the same code, such as git merge and git revert for the cleanup rules.
git config commit.template ~/.gitmessage.txt git config --global commit.verbose true git config --global commit.gpgSign true git config commit.cleanup strip
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
git config commit.template <path> git config commit.gpgSign (true | false) git config commit.verbose (true | false | 2) git config commit.cleanup (strip | whitespace | verbatim | scissors | default) git config commit.status (true | false) git config commit.signoff (true | false)
| Name | Description |
|---|---|
commit.template |
File whose content pre-fills the message editor. A leading ~/ is expanded; a relative path is taken from the repository root. |
commit.gpgSign |
Sign every commit (as if -S were given); --no-gpg-sign overrides it. See gpg.*. |
commit.verbose |
Include the diff of what will be committed in the editor, below a scissors line. 2 also shows the unstaged diff. |
commit.cleanup |
How the message is tidied: strip removes comments, leading and trailing blank lines, trailing spaces and repeated blank lines; whitespace keeps comments; verbatim changes nothing; scissors cuts at the scissors line; default picks strip when an editor opens and whitespace otherwise. |
commit.status |
Include the git status text as comments in the editor (default true). |
commit.signoff |
Add a Signed-off-by: trailer automatically to every commit, like -s (a recent addition; not available in older Git versions). |
Errors: a missing template file stops the commit with fatal: could not read '<path>'. An unknown cleanup mode fails with Invalid cleanup mode.
Usage notes
- Templates are only used when an editor opens. Messages given by
-m,-For-Cignore the template. - An unchanged template aborts the commit, because the message is considered empty. This is the point: it stops you from committing the placeholder text.
commit.verbosehelps you write accurate messages because you see the diff while typing. Nothing from the diff ends up in the message.- Signing everything with
commit.gpgSignmakes every commit prompt for a passphrase unless an agent is running. Teams often enable it for release branches only. - Per-repo versus global: a template referencing a project convention (ticket IDs) belongs in the repository config; personal editor settings in
--global; seecore.editor. - Merge and revert messages go through the same
cleanuprules, which is why#comment lines you leave in a merge message disappear. - Comment character:
core.commentChar(orcore.commentStringin recent versions) changes#to something else, useful when messages start with#123issue numbers.
Related
git commit,git commit --amend,core.editor,gpg.*- Lessons: Commits, Signing and security