Easy to set up git hooks that can be shared by your projects.

Usage no npm install needed!

<script type="module">
  import 4thMotionGitHooks from 'https://cdn.skypack.dev/@4th-motion/git-hooks';



Easy to set up git hooks that can be shared between your projects.

Version License

Handle all your git hooks in one place and share them between your projects. Changes can be made at any time - old configurations are automatically overwritten because there's only one source of truth.



Add this package as a devDependency to your project:

yarn add --dev @4th-motion/git-hooks


Once the package is installed, you can initiate it with:

yarn 4th-git-hooks

Now you can specify the tasks to be performed on a particular hook. The tasks must be present in the script field in package.json.

  "git": {
    "pre-commit": ["lint", "test"]

Note that the commit-msg hook is always executed. This ensures that commits can only be pushed with certain keywords (e.g. feat, fix, …) and never to the master branch. If you do not want to activate this hook, just remove it from the hooks/ folder.

Behind the scenes

The initialization process extends the package.json file as follows:

  "scripts": {
    "postinstall": "4th-git-hooks"

This will copy all git-hooks from the hooks/ directory during each installation. You can always edit existing hooks or add new hooks. A list off all git hooks can be found here.

Further documents

Related projects

@4th-motion/eslint-config @4th-motion/stylelint-config
@4th-motion/eslint-config @4th-motion/stylelint-config


Copyright © 2020 by 4th motion GmbH. Released under the MIT License.