Skip to content

Instantly share code, notes, and snippets.

@shawnzhu
Created June 2, 2017 20:49
Show Gist options
  • Save shawnzhu/804b7e5618eaced72dc592e0cd36ca64 to your computer and use it in GitHub Desktop.
Save shawnzhu/804b7e5618eaced72dc592e0cd36ca64 to your computer and use it in GitHub Desktop.
a commit-msg git hook
#!/bin/bash
COMMIT_MSG="$(head -n 1 "$1")"
if [[ "${COMMIT_MSG:0:1}" =~ [^A-Z] ]]; then
>&2 echo Commit message must be capitalized.
exit 1
fi
@shawnzhu
Copy link
Author

shawnzhu commented Jun 2, 2017

How to install it

  1. install git hooks by following this guide: https://github.com/git-hooks/git-hooks#install
  2. run command git hooks install under your git repo directory
  3. save this gist under ~/.githooks/commit-msg like ~/.githooks/commit-msg/capitalize

How to use it

when you run command git commit -m "<something>", it will fail if the commit message is not capitalized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment