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.
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!
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.
pre-commit
prepare-commit-msg
commit-msg
To install the template and git-hooks, run:
sudo ./setup_hooks.sh install_hooks
The script will:
- Find all directories under the
/home
which contain any.git
directory - Install the hooks into them
- Sets
init.templateDir
to point totemplates/git-commit-template.txt
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.