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
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.
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
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à!