Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 871
Zubatman Avatar asked Nov 16 '25 19:11

Zubatman


1 Answers

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

like image 50
Zubatman Avatar answered Nov 19 '25 09:11

Zubatman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!