What is a pre-commit hook?
Definition and use cases for the Git pre-commit hook.
Definition
A pre-commit hook is a specific Git hook that runs automatically when you execute the "git commit" command, but before you are prompted to write a commit message. If the script exits with a non-zero status, the commit is aborted.
Use Cases
It is the most popular Git hook, used universally as a quality gate to run ESLint, Prettier, Black, or other code formatters and linters on staged files.