Skip to content

Instantly share code, notes, and snippets.

@spraints
Created August 3, 2012 15:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save spraints/3248724 to your computer and use it in GitHub Desktop.
Save spraints/3248724 to your computer and use it in GitHub Desktop.
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://github.com/icefox/git-hooks.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
/Users/you/.git_hooks:

//git_hooks:

//.githooks:

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://github.com/spraints/git-hooks.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.

Poacher

mkdir -p ~/.git_hooks/pre-commit
curl -L -o ~/.git_hooks/pre-commit/no-debugger https://github.com/spraints/git-hooks/raw/master/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