This project has been superseded by pre-commit-hooks A framework for managing and maintaining multi-language pre-commit hooks, which is far more flexible and feature-rich than this project can provide.
It is recommended to use that instead.
A simple shell script to support per-repository Git hooks, checked into the actual repository that uses them.
To make this work, it creates hook templates that are installed into the
.git/hooks folders automatically on
git init and
git clone. When one of them executes, it will try to find matching files in the
.git/hooks directory under the project root, and invoke them one-by-one.
Check out the blog post for the long read!
Layout and options
Take this snippet of a project layout as an example:
├── hooks │ ├── commit-msg │ ├── pre-commit │ └── prepare-commit-msg ├── LICENSE ├── pip-requirements.txt ├── README.md ├── setup_hooks.sh └── templates └── git-commit-template.txt
The supported hooks are listed below. Refer to the Git documentation for information on what they do and what parameters they receive.
To install the template and git-hooks, run:
sudo ./setup_hooks.sh install_hooks
The script will:
- Find all directories under the
/homewhich contain any
- Install the hooks into them
init.templateDirto point to
If you want to get rid of these hooks and templates, you can run:
sudo ./setup_hooks.sh delete_hooks
This will delete the template files, optionally the installed hooks from the existing local repositories.