Lint git commit message style
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

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

Git Lint

Scrutinizer Code Quality Build Status Dependency Status Latest Stable Version License

This project is designed to ensure that the commits you're making to a repository follow the git coding style. This is simply the basic validators.

The standard that they test for is the one described by Chris Beams.

The validations it implements are:

  • Separate subject from body with a blank line
  • Limit the subject line to 50 characters (soft limit, hard limit at 69)
  • Capitalize the subject line
  • Do not end the subject line with a period
  • Wrap the body at 72 characters

Getting Started


You'll need to install:

  • PHP (Minimum 7.0)


composer require --dev PurpleBooth/git-lint-validators



You can try out this library by using it as a git commit hook.

Git hook installation

Use the install-git-hook Composer script to install the hook. An existing hook is backed to .git/hooks/commit-msg.bak.

composer install-git-hook

It's fairly customisable too, here are some options:

$ vendor/bin/git-lint-validators help git-lint-validator:hook
  git-lint-validator:hook [options] [--] <commit-message-file>

  commit-message-file                Path to commit message file

  -i, --ignore[=IGNORE]              Ignore a commit message that matches this pattern and don't test it [default: ["/^Merge branch/"]] (multiple values allowed)
  -c, --comment-char[=COMMENT-CHAR]  Ignore lines that are prefixed with this character [default: "#"]
  -h, --help                         Display this help message
  -q, --quiet                        Do not output any message
  -V, --version                      Display this application version
      --ansi                         Force ANSI output
      --no-ansi                      Disable ANSI output
  -n, --no-interaction               Do not ask any interactive question
  -v|vv|vvv, --verbose               Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

 Check your commit messages to ensure they follow the guidelines described by Chris Beams.
 To enable the Git hook in your project run 'composer install-git-hook.'

 Here are some good articles on commit message style:


Output While Running

$ git commit

 [ERROR] Incorrectly formatted commit message

 * Please limit the body line length of the commit message to 72 characters (

Your Commit Message

 Add commit message to output of hook

 It can be frustrating if you've lost a large git commit message because it
 doesn't match the style guide. This will add a little message including
 your commit details
 # Please enter the commit message for your changes. Lines starting
 # with '#' will be ignored, and an empty message aborts the commit.
 # On branch added-original-commit-message-to-hook
 # Changes to be committed:
 #  modified:   src/PurpleBooth/GitLintValidators/Command/Hook.php

 [WARNING] A commit has not been created

Git commit message template installation

Use the install-git-commit-message-template Composer script to install and configure a commit message template following the rules of Chris Beams. The commit message template is written to .git/.gitmessage and will than be used when issuing a git commit w/o the message option.

composer install-git-commit-message-template


You can use the whole library


$validatorFactory = new ValidatorFactoryImplementation();
$validators       = $validatorFactory->getMessageValidator();

    = <<<MESSAGE
This is an example title

This is a message body. This is another part of the body.

$exampleMessage = new MessageImplementation("exampleSha", $message);

// -> Message Object will now have a Status objects set on them

Alternatively you could use the validators alone


new ValidateMessageImplementation(
        new CapitalizeTheSubjectLineValidator(),
        new DoNotEndTheSubjectLineWithAPeriodValidator(),

    = <<<MESSAGE
This is an example title

This is a message body. This is another part of the body.

$exampleMessage = new MessageImplementation("exampleSha", $message);

// -> Message Object will now have a Status objects set on them

Please depend on the interfaces rather than the concrete implementations. Concrete implementations may change without causing a BC break, interfaces changing will cause major version increment, indicating a BC break.

Running the tests

First checkout the library, then run

composer install

Coding Style

We follow PSR2, and also enforce PHPDocs on all functions. To run the tests for coding style violations

vendor/bin/phpcs -p --standard=psr2 src/

Unit tests

We use PHPSpec for unit tests. To run the unit tests

vendor/bin/phpspec run


Please read for details on our code of conduct, and the process for submitting pull requests to us.


We use SemVer for versioning. For the versions available, see the tags on this repository.


See the list of contributors who participated in this project.


This project is licensed under the MIT License - see the file for details.