Zubatman
Zubatman

Reputation: 1305

Universal Post Commit Git Hook

I was wondering if there was a simple way to set up a post commit git hook so that it would run regardless of the repo that it is run with (It is my understanding that the applied hook comes from a hook/ folder in the git directory).

Thank you!

Upvotes: 3

Views: 357

Answers (1)

Zubatman
Zubatman

Reputation: 1305

This actually has a relatively simple answer, but it was a nightmare to find. Here's the terminal commands I used to do it, it works perfectly.

git config --global init.templatedir '~/.git-templates'
mkdir -p ~/.git-templates/hooks
cp post-commit ~/.git-templates/hooks/
chmod a+x ~/.git-templates/hooks/post-commit

In this example post-commit is an executable bash script

Upvotes: 4

Related Questions