Git Hooks
You run git commit and it just works, every time. Then one day it stops, refuses, and prints a line you wrote yourself, because a plain script sitting in .git/hooks/ returned a number git did not like.
- ▸A hook is one executable file in
.git/hooks/, named right andchmod +x, that git forks and checks. - ▸It never rides along with a clone; sharing hooks means pointing
core.hooksPathat a tracked folder. - ▸
--no-verifyskips only your copy; the server's hook still runs and can turn the push away.
Run git init and look inside the new repo: ls .git/hooks/ lists 14 files, every one ending in .sample, pre-commit.sample, commit-msg.sample, pre-push.sample, and more. cat any of them and it is plain shell script, no special header, no registration line. They ship with every repo and not one of them ever runs.
The reason is the filename. When git is about to record a commit, it looks in .git/hooks/ for a file named exactly pre-commit, no extension. pre-commit.sample does not match that name, so git walks past it. Drop the .sample suffix, or write your own file called pre-commit, and the next git commit finds it and runs it as a child process. Rename it to precommit or pre_commit and git ignores it again; the match is exact.
That is the whole trigger. There is no list you add the file to, no config that points at it, no daemon watching. git resolves the moment (commit, push, merge) to a fixed filename and runs whatever executable sits at that name. The file existing, spelled right, is what makes the moment fire a script of yours.
In the viz you hold the directory. Name a file, pick a moment, and watch git either find an exact match and run it or walk past a near-miss.