To use, just add the content of the wanted hook in .git/hook/pre-commit. You may need to use chmod +x pre-commit
.git/hook/pre-commit
chmod +x pre-commit