Is there a good way I can share the code in .git/hooks
?
The only thing I can think of is to create command line tools, and call those tools from each script in .git/hooks/*
Is there a good way I can share the code in .git/hooks
?
The only thing I can think of is to create command line tools, and call those tools from each script in .git/hooks/*
Create a git repo on github. Clone it to your fs. Symlink the hooks files to .git/hooks/*
, or better yet, use:
git config core.hooksPath .githooks
which will tell .git to use the .githooks
folder in your project to look up the hooks, instead of .git/hooks
You can either:
git add --chmod=+x
) and describe in the README
of said repo what a user needs to do to activate it (for instance a symbolic link from .git/hooks/pre-commit
to your script)My suggestion: https://githooks.com/
There are a few ways to manage hooks. I ended up creating one for myself and made it public weeks ago: https://github.com/lovato/hooks4git
In my approach, there are no global scripts (like other tools or even git properly configured). Once the tool is installed and activated on your repo, you commit your scripts along with your code.
In any approach, you can link files to an external repo, and have all your scripts shared, without actually needing to touch .git/hooks folder directly.