Skip to content
This repository has been archived by the owner. It is now read-only.
My personal githooks
Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
hooks
templates
.stickler.yml
LICENSE
README.md
pip-requirements.txt
setup_hooks.sh

README.md

Git-hooks

Deprecation Notice

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.

GitHub

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

Supported hooks

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

Installation

To install the template and git-hooks, run:

 sudo ./setup_hooks.sh install_hooks

The script will:

  1. Find all directories under the /home which contain any .git directory
  2. Install the hooks into them
  3. Sets init.templateDir to point to templates/git-commit-template.txt

Uninstalling

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.

You can’t perform that action at this time.