mblakele / git-hooks-js

A tool to manage and run project git hooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

git-hooks-js NPM version Build Status

git-hooks is an utility for managing and running project git hooks.

Just install git-hooks and it will run your hooks when a hook is called by git.

Why do you need git hooks in your project?

Hooks are little scripts you can place in $GIT_DIR/hooks directory to trigger action at certain points.

They are very powerful and helpful.

You can do a lot of things with them:

Note. When you use git-hooks, you should not modify $GIT_DIR/hooks directory manually because git-hooks will do it for you.

Install

Install git-hooks in your project.

npm install git-hooks --save-dev

To keep things organized, git-hooks looks for scripts in sub-directories named after the git hook name. All these sub-directories should be stored in .githooks directory in the project root.

Let's create some dummy pre-commit hook.

mkdir -p .githooks/pre-commit
echo -e '#!/usr/bin/env node' "\nconsole.log('hello, world');" > .githooks/pre-commit/hello.js
chmod +x .githooks/pre-commit/hello.js

Then just try to commit and see how things are rolling.

git add .githooks package.json
git commit -m "Add git-hooks"

See also hooks examples.

Related projects

About

A tool to manage and run project git hooks


Languages

Language:JavaScript 95.9%Language:Shell 4.1%