blob: beb27376d1999bcce18b8ae30547c4f81d003e0d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
git-hooks - A tool to manage Git hooks for multiple git repositories.
Hooks can be very powerful and useful. Some hooks that can be found include:
- Spell check the commit message.
- Check that the code builds.
- Verify that any new files contain a copyright with the current year in it.
Hooks can also be very project specific such as:
- Verify that any new code follows the coding style (this is always different)
or very people specific such as:
- Don't allow me to push after 1am in case I break something.
- Don't let me commit between 9-5 for projects in ~/personal/ as I shouldn't be working on them.
git-hooks provide a way to manage and share your hooks by allowing for the installation of hooks in three locations:
- User hooks that are installed in ~/.git_hooks/
- Project hooks that are installed in the git_hooks directory of each project
- Global hooks that are specified with the environment variable GLOBAL_GIT_HOOKS.
When GLOBAL_GIT_HOOKS is not set it defaults to the git-hooks /contrib/ folder.
Multiple global hooks directories can be specified by using a space between them.
--- Creating hooks
To keep things organized git-hooks looks for scripts in sub directories named after the git hook name. For example this project has the following pre-commit script in the following location:
git_hooks/pre-commit/bsd
When you run 'git hooks' with no arguments it will list all of the hooks installed on the system. It will run the hooks with the --about argument to generate the description that is shown.
-- Install
Clone the git-hooks repository and add it to your path.
Inside a project's directory run 'git hooks --install' to change that projects git hooks (which defaults to doing nothing) to use git-hooks hooks.
|