Git multi-hook template.

  • git clone https://klva.cz/src/tools/hook.d.git
  • README: Make it more obvious you only need to do one thing to install this. 8ef2f14, 18 Jan 2023
    template/
    .editorconfig
    .gitattributes
    hook.d
    install
    Makefile
    README.md

    hook.d

    This repository contains a Git template with multi-hooks.

    Multi-hook runs every executable file in the respective <hook>.d folder (such as post-checkout.d/switch-database), passing all the hook's arguments and stdin to it. Files are executed in alphabetical order; a non-zero exit code is propagated back to Git, preventing any further hook from running.

    Installation

    Using templates

    You can use Git's template directory to automatically create all the hooks on repository initialization.

    git config --global init.templateDir /path/to/hook.d/template
    

    You can also use the template for a specific repository, including the existing ones.

    git init --template /path/to/hook.d/template
    

    Using the installation script

    Finally, install script takes care of installing all the hooks and creating their respective directories. Run the following command from within your repository.

    /path/to/hook.d/install
    

    Usage

    Create a file inside a hook subdirectory and make it executable.

    mkdir -p .git/hooks/pre-commit.d
    touch .git/hooks/pre-commit.d/05-precommit-hook
    chmod +x .git/hooks/pre-commit.d/05-precommit-hook