Skip to content
masterclass Buddy

Git · Option

pre-commit hook

The pre-commit hook runs before Git creates a commit. It can inspect the staged snapshot and stop the commit by exiting with a nonzero status.

Last updated

Syntax

.git/hooks/pre-commit

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • git-commit
  • commit-msg
  • prepare-commit-msg
  • pre-merge-commit
  • hooks.allownonascii
  • --no-verify

Source: Git - githooks Documentation. Checked 2026-11-03.