We'll create our own workflow with Git and Hooker!
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.githooks
examples
.gitattributes
.gitignore
LICENSE
README.md
hooker.sh

README.md

Hooker

We'll create our own workflow with Git and Hooker!

Hooker is a small shell script that lets you easily set up and manage hooks for your git repositories.

Install

$ curl https://raw.githubusercontent.com/joshfriend/hooker/master/hooker.sh
$ ./hooker.sh --install
Hooking you up...

Note: This process will overwrite any existing git hooks!

How It Works

Hooker installs itself with a symlink as the following git hooks (see the docs for details on when each of these is executed and what arguments they take):

  • applypatch-msg
  • commit-msg
  • post-update
  • pre-applypatch
  • pre-commit
  • pre-push
  • pre-rebase
  • prepare-commit-msg
  • update

When Git runs a hook, Hooker will look in the .githooks directory in your repo root for a folder with the name of the hook that Git is running. All executable scripts in that folder will be executed in alphabetic order. If one of the hooks returns a non-zero exit code, any remaining hooks are skipped and Hooker will indicate hook failure to Git.

Example

Given a .githooks directory containing the following:

repo/
    .githooks/
        pre-commit/
            bar.py
            foo.sh

Contents of bar.py:

#!/usr/bin/env python
print 'bar'

Contents of foo.sh:

#!/bin/bash
echo "foo"

Running git commit will have this result:

$ git commit
bar
foo
Aborting commit due to empty commit message.

More examples can be found in the examples/ directory

Skipping Hooks

If you would like to bypass your hooks temporarily, just pass an additional --no-verify flag to any Git operation. For more info read the githooks(5) manpages:

$ man githooks

The --no-verify flag is all-or-nothing. You cannot skip individual hooks selectively.