Skip to content
Edit this page View source of this page

Git commit hooks

Git runs hooks at specific points during a commit. In this template, the hooks give contributors feedback in their own checkout before they push.

Hook What happens
pre-commit Prek checks the files staged for the commit. Depending on the file, a hook might validate its syntax, report a lint error, or rewrite it.
commit-msg Commitizen checks the proposed commit message against Conventional Commits. A rejected message needs to be edited before Git can create the commit.

When the hooks are installed

The template's mise entry hook runs scripts/enter_project.sh. If Prek is available, the script installs missing hooks and replaces existing hook files that do not already mention prek. This happens in each local checkout where the entry hook runs. You can also install both hooks explicitly after setup.

prek install

To find where Git normally places the hooks in your checkout, run git rev-parse --git-path hooks. If Git has a core.hooksPath override, check it with git config --show-origin --get core.hooksPath when diagnosing a hook that never runs.

When a check fails

If a hook rewrites a file, review the diff and stage the intended changes before retrying the commit. If it reports a diagnostic, fix the file and run that hook again. GitHub runs a separate repository checks job, so contributors also get feedback in the pull request.

Run repository checks · Prek configuration · Commit messages