Simple git hook to enforce commit mesage

31 Aug 2020 | git hook

Setting up Simple git hook to enforce a commit message

If you’re working on a project with other people and want to have a consistent commit log, here’s a simple git commit hook to enforce a particular format.

I prefer to use the format #<issue number> | <commit message>


# In your repo...
$> vi .git/hooks/commit-msg
#!/bin/sh

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

Older · View Archive (17)

Setting up a journal in less than one hour using vim

So I have been extolling the benefits of journalling to a few friends over the past few months - how it is a way to reflect a bit more deeply on your thoughts, figure out what excites you, interests you or just plain scares you. It is a great way to shut up, shut the outside world and enjoy some solitude!