Back to directory
captainhook-git avatar
captainhook-git / captainhook-bin

captainhook-bin

CaptainHook is a very flexible git hook manager for software developers that makes sharing git hooks with your team a breeze.

31

Stars

2

Forks

1

Watchers

MIT

License

Version License Go Report Card Go Version Go Reference Mastodon

CaptainHook

CaptainHook logo

CaptainHook is an easy to use and very flexible git hook manager for software developers. It enables you to configure your git hook actions in a simple json file and easily share them within your team.

You can use CaptainHook to validate or prepare your commit messages, ensure code quality or run unit tests before you commit or push changes to git. You can automatically clear local caches or install the correct dependencies after pulling the latest changes.

You can run your own commands or use loads of built-in functionality. For more information have a look at the documentation.

Installation

You can download the application binary for your platform from the release page. Or use one of the following options.

Use Homebrew to install CaptainHook.

brew tap captainhook-git/captainhook
brew install captainhook

Use go install to install CaptainHook.

go install github.com/captainhook-git/captainhook-bin/cmd/captainhook@latest

Setup

After installing CaptainHook, navigate to your project directory and use the captainhook init command to create a configuration file.

cd my-project-repo
captainhook init

As soon as you have a configuration file the only thing left is to activate the hooks by installing them to your local .git/hooks directory. To do so just run the following captainhook command.

captainhook install

Configuration

Here's an example captainhook.json configuration file.

{
  "hooks": {
    "commit-msg": {
      "actions": [
        {
          "run": "CaptainHook.Message.MustFollowBeamsRules"
        }
      ]
    },
    "pre-commit": {
      "actions": [
        {
          "run": "unittest"
        }
       ]
    },
    "pre-push": {
      "actions": [
        {
          "run": "CaptainHook.Branch.PreventPushOfFixupAndSquashCommits",
          "options": {
            "branches-to-protect": ["main", "integration"]
          }
        }
      ]
    }
  }
}

Contributing

So you'd like to contribute to CaptainHook? Excellent! Thank you very much. I can absolutely use your help.

Have a look at the contribution guidelines.

Releases

Changelog

832881f Fix documentation link dfd8685 GitHub org and repo rename

Jul 25, 2025

Download .zip

Changelog

6dcb528 Add YAML config loading functionality 9ae1f5c Add yaml marshal models e32b720 Allow both :: and . for internal exec placeholders b8186cc Move json specific create methods

Changelog

6ca30db Allow absolute core.hooksPath config setting 6d64e09 Skip install on /dev/null core.hooksPath

Changelog

c723abe Check for broken symlinks before install 5fed7c5 Fix typos

May 25, 2025

Download .zip

Changelog

45f6ad3 Add function docs 24f4d66 Add function docs 46525e1 Fix brew tap url ef2cc78 GitHub org rename