Skip to content

Instantly share code, notes, and snippets.



Forked from spraints/
Created Jul 29, 2018
What would you like to do?
Set up git-hooks

Install git hooks

git-hooks is a tool that makes it easy to re-use hook scripts across projects.

I installed it by cloning the repo and symlinking it into /usr/local/bin.

git clone git://
cd git-hooks
ln -s `pwd`/git-hooks /usr/local/bin/git-hooks

To check if it's installed, run git hooks. You should see something like this:

fatal: Not a git repository (or any of the parent directories): .git
Git hooks are NOT installed in this repository.

Listing User, Project, and Global hooks:
fatal: Not a git repository (or any of the parent directories): .git



Set up your hooks

I have mine in a git repo, of course. :) Feel free to use mine, or poach from it.

Use mine

git clone git:// git-hooks-spraints
cd git-hooks-spraints
ln -s `pwd`/hooks ~/.git_hooks

Now, when you run git hooks, you should see a couple hooks listed under /Users/you/.git_hooks.


mkdir -p ~/.git_hooks/pre-commit
curl -L -o ~/.git_hooks/pre-commit/no-debugger

git hooks should show you the one available hook.

# Install hooks in a repo

`cd` to the repo you want hooks in. `git hooks --install`. `git hooks` will now show that it's all installed & ready. Now, just TRY to check something in with `debugger` (or `raise`). :)

## Onoes! I really do want to commit that!

You just ran `git commit ...` and git threw some debugger or raise lines back at you. You checked that those lines are OK to commit (or, sometimes, it finds lines that aren't staged, so it's OK that they exist). To make the commit go through, run `git commit ... --no-verify`. Voilà!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment