Disclaimer: info. for this page was sourced from here
Git hooks allow us to run custom scripts at the time of certain life cycle events like committing, merging, pushing etc.
Hooks are stored in .git/hooks
. There are many sample templates available in this directory after git init
is executed. To enable one of these sample scripts all you need to do is remove the sample
extension. Git is targeting specific file names to execute at the corresponding life cycle event.
- If a script exists with a
0
exit code then the script succeeded and the process moves on. To stop execution at the hook then an exit code of anything other than0
must be returned from the script. - Hooks are not checked into source control, therefore if you delete your local directory then they will be gone.
- The
--no-verify
flag can bypass all hooks easily.