Hooks
Hooks are local to a git repo they are not copied over to the new repository when you run git clone
In shared dev team, typically hooks are stored in the project directory itself in a seperate hooks
directory, which is version controlled.
A new dev needs to either symlink or copy hooks
to local .git/hooks
Sample hook files are by default generated by git in a git repo in the directory .git/hooks
. The .sample
suffix of the filenames prevent them from executing
Hooks are simple executable scripts, by default sh
, but can be written in any scripting language using #!/usr/bin/env <executable>
Client Side (local) Hooks
pre-commit
prepare-commit-msg
commit-msg
post-commit
post-checkout
pre-rebase
Server Side Hooks
pre-receive
: called once before receiving the pushed changesupdate
: called every time before aref
is updated i.e. before every commit being added to remote repopost-receive
: called once after thepush
for all refs is completed
References
manpage: https://git-scm.com/docs/githooks
useful examples: https://www.atlassian.com/git/tutorials/git-hooks