The script checks that git commit messages are formatted according to certain guidelines documented in guidelines.txt
.
The checker should catch common errors, but it cannot provide perfect validation.
- Give the
commit-msg
file permissions to execute, e.g.chmod u+x commit-msg
- Copy the
commit-msg
file into the.git/hooks
folder of your git repository. - The script will be executed by git locally when a git commit is performed.
The script is also known as a git hook.
The advantage to running the script locally is that it is simple and errors can be caught before a commit is done. The downside is that the user may forget to install or update the script, or bypass it altogether.
The alternative is to install a server-side hook, so that the script runs when a push is done. If the check fails, the push will be rejected. To do this, rename the script to use an appropriate hook. Remember to handle different arguments specific to each different hook.