This package is abandoned and no longer maintained. The author suggests using the package instead.

Library for automatically copying git hooks into a project

dev-feature/prepare-command 2017-09-26 02:32 UTC

This package is auto-updated.

Last update: 2020-07-22 16:25:55 UTC


Build Status Code Climate Test Coverage Packagist

Smee is a Composer package designed to make it easier to share Git hooks with a project.

Why Git hooks?

Git hooks are a useful way to automatically perform actions at different points throughout the Git lifecycle. These actions could include verifying coding standards, running unit tests, enforcing commit message formats, and more.

The downside to Git hooks is that they're not distributed with the Git repository, meaning it's difficult to ensure that all developers on a project are using the same hooks.

Smee aims to change that, by introducing the .githooks directory and providing an easy way to automatically install the hooks on composer install.


Smee should be added to your projects via Composer:

$ composer require --dev stevegrunwell/smee

To ensure Smee is automatically run for other users, add Smee to the "post-install-cmd" Composer event:

    "scripts": {
        "post-install-cmd": [
            "smee install"

Finally, create a .githooks directory in the root of your project, and add the hooks you'd like to use in your project. These files should be committed to the git repository, and will automatically be copied into other developers' local repositories the next time they run composer install.

Available Git hooks

Git supports a number of hooks, which each fire at different points throughout the lifecycle. Each Git hook exists in a separate file, named after the hook it corresponds to (e.g. .git/hooks/pre-commit will be executed on the "pre-commit" hook).

Commit workflow

These are some of the most common Git hooks, firing at different points as a developer attempts to commit code:

Runs before a commit message is created.
Run before the commit message editor is opened but after the default message is created.
Runs before saving the commit message, often used for verifying commit message format.
Runs after a commit has been made. This hook is typically used for notifications.

Email workflow

Git also supports an email-based workflow via git am, which applies patches in sequence from a mailbox. If you're using this workflow, a few additional hooks are available.

Other useful client-side Git hooks

Runs before allowing any code to be rebased.
Runs after rewriting a commit, e.g. git commit --amend.
Runs after a successful git checkout command.
Runs after a successful git merge command.
Runs before a git push command.
Runs before Git's periodic garbage collection processes.