Copy this file under the name
pre-commit into your repository's
.git/hooksdirectory. You may need to use
chmod +x to enable execution.
Script exscution can be skipped with
git commit --no-verify which can skip lengthy test execution on simple changes to documentation.
If you have used
git add --patch to add an edited hunk, stashing and then unstashing changes will inevitably result in a merge conflict blocking your commit and ruining your day. In this case, use
git commit --no-verify.