Git Commit Hooks

Pre-commit

Runs before a commit. This is useful to verify that the commit message follows the correct format. It can also be used to regenerate files before committing.

See for example the landdown pre-commit hook which regenerates the readme page before committing.

Post-receive

Useful to trigger CI pipelines. See for example Git Repo Tutorial.

Pre-receive

Useful to restrict access to a repository. Can be used to set up protected branches or protected files.

Post-commit

Useful if you want to have tests run in the background locally. See Local Test CI Using Git Hooks and Notes.