Global Git Hooks
You can create global git hooks by:
- setting $GITTEMPLATEDIR
- git init --template ~/.mygittemplatesorsomething
- putting your scripts in $GIT_PREFIX/git-core/templates/hooks
I made one that takes a picture every time I commit. I recommend it for personal amusement.
Written by Joseph Randall Hunt
Related protips
2 Responses
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/37183/aae6d4accf06084efc742f85d3806b33.jpeg)
Would like to add that you can:
- place your hook into
$PREFIX/share/git-core/templates/hooks
where$PREFIX
is/usr
or/usr/local
to make that hook "global". - place your hook into home dir somewhere just like this tip suggests and set init.template_directory git variable to point that dir, instead of explicitly specifying it every time.
See: http://stackoverflow.com/questions/2293498/git-commit-hooks-global-settings
over 1 year ago
·
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/22976/79c320d5af1feee21c58b8cb21692d38.jpeg)
yes your first suggestion is the same as III
the issue with that one is that whenever you update git it will often remove the hooks :(
I like your second one.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Git
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#