Last Updated: February 25, 2016
·
2.387K
· ranman

Global Git Hooks

You can create global git hooks by:

  1. setting $GITTEMPLATEDIR
  2. git init --template ~/.mygittemplatesorsomething
  3. 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.

2 Responses
Add your response

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 ·

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 ·