Last Updated: September 01, 2020
·
302
· Rajiv Nair

Git hook to enforce commit message in the format "#<issue number> | <message>"

$ vi .git/hooks/commit-msg

#!/bin/sh
test "" != "$(grep -Ei '^#[0-9]+\s?\|' "$1")" || {
    echo >&2 Yo! Commit message needs to be in the form '#<issue number> | <text message>'.
    exit 1
}