Appearance
Examples
Check the length of the checked-out commit:
shellgit commit-message-summary-length
Amend if the message is longer than you prefer:
shellgit commit-message-summary-length || git commit --amend
Print
ok
iforigin/main
's second ancestor commit's message is 47 characters long or shorter:shellgit commit-message-summary-length --error-after=47 --log-level=0 origin/main~2 && echo ok
Configure for GitHub, which in some parts of the web UI truncates messages longer than 72 characters to 69 characters:
shellgit config --global commit-message-summary-length.warnafter 69 git commit-message-summary-length
Automatically run after every commit:
Configure
git config --global init.templatedir
if you haven't already.shellgit config --global init.templatedir # if no output git config --global init.templatedir ~/.config/.git-templates`
Add a
post-commit
hook file, and add a git-commit-message-summary-length command to it.shellmkdir -p $(git config --global init.templatedir)/hooks echo "git commit-message-summary-length" >> $(git config --global init.templatedir)/hooks/post-commit chmod +x $(git config --global init.templatedir)/hooks/post-commit
Type less:
shellgit config --global alias.l commit-message-summary-length
Or if your shell has native abbreviations (like fish) or an abbreviations plugin (like zsh's zsh-abbr, by the creator of git-commit-message-summary-length), create an abbreviation for
git commit-message-summary-length
. (l
is nice and short.)