June 2025
Beginner to intermediate
473 pages
13h 30m
English
Git hooks are scripts that are automatically executed before or after certain Git actions. In each new Git repository, you’ll find a collection of script patterns for various actions in the .git/hooks directory:
$ ls .git/hooks applypatch-msg.sample prepare-commit-msg.sample commit-msg.sample pre-push.sample fsmonitor-watchman.sample pre-rebase.sample post-update.sample pre-receive.sample pre-applypatch.sample push-to-checkout.sample pre-commit.sample update.sample pre-merge-commit.sample
The sample files are well documented shell scripts. A look into these files not only reveals the purpose of the respective hook, but also immediately shows working sample code.
To activate a hook, you must remove the .sample identifier. (Unlike ...
Read now
Unlock full access