SuperHooks is a quick way to have hooks apply across multiple projects. It allows you to decouple the hooks you use from the projects you use them in by pacing the hooks into separate folders.
Hooks are defined at three levels:
- Global hooks : hooks available everywhere
- User hooks : hooks used for your own user
- Project hooks : hooks used only for a project
Once a hook gets invoked from
git, all the different types of hook will run.
brew tap frankywahl/tap brew install frankywahl/tap/super_hooks
Installation from source
- go: to install it yourself from source
This will create a binary tagged with the commit you're currently on
super_hooks into a git repository:
List the current hooks:
See the other options with:
|User Hooks||indicated by your
|Project Hooks||indicated by your
|Global Hooks||indicated by your
The way most people work is to have a single folder with all hooks for them.
git config --global hooks.global `pwd`
Note: You can have multiple
hooks.global configurations by either:
- adding them with the command:
git config --add hooks.global </path/to/hooks/directory>
- adding the paths in a comma separated value way
super_hooks is installed, you can easily create hooks by placing executables files (
chmod 755) under a folder with the hook name.
For example, if you were to create a pre-commit hook for your user, you would do the following:
mkdir -p ~/.git_hooks/pre-commit/ git config hooks.user ~/.git_hooks touch ~/.git_hooks/pre-commit/cool_hook chmod 755 ~/.git_hooks/pre-commit/cool_hook
Note: having a
--about option when running your executable will allow you to have a short description when listing hooks. See my rake example for this project.
Example: I have my own hooks which I have installed for all of my projects:
git clone firstname.lastname@example.org:frankywahl/git_hooks.git somewhere cd somewhere git config --global hooks.global `pwd`
You can get help on the command line to see supported commands:
Then for a specific operation example
super_hooks install --help
- Fork it ( https://github.com/[my-github-username]/super_hooks/fork )
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create a new Pull Request
Copyright (c) 2020 Franky W.