All Git repository should be created following a template which includes a .git/hooks/hooks--pre-commit.sample
Rename that file in hooks--pre-commit
, make sire it is executable (unless you are on Windows), and that hook will be triggered automatically on commits, with the code you will have put in int.
Your article actually refers to a global hook:
The global git hooks live in $PREFIX/share/git-core/templates/hooks
(where $PREFIX
can be /usr/local/git
, from whoami - fakeFaceTrueSoul's comment).
Rename the pre-commit.sample
file to pre-commit to activate it.
On Windows, that would be in:
c:\gits\current\mingw64\share\git-core\templates\hooks>l
total 41K
-rwxr-xr-x 1 dchaffiol 1049089 1.6K Nov 6 14:43 pre-commit.sample*
On Mac, $PREFIX
would be $(brew --prefix git)
or just brew --prefix
, as seen here.