Git hooks centralization
An easy and good way to use your hooks in all your repositories wherever they are
Père, mari, développeur, geek, coffee lover, amateur dans beaucoup de domaines
Hello world!
Recently, I created a Git hook which prefix all my commit titles by a Jira story id. After that, a new problem blocked me: I want to use this hook at work in all my repositories. How to do that easily (and automatically)?
I heard about some methods which does not satisfied me. The first one, for sharing hooks, is to create a hook repository and pointing on it with a symbolic link. This method can work. But, you have to create the symlink on each repo which will use the hooks folder. That's boring if you have to add the link in a lot of repos and, for new ones, you may forget to create the link. I definitely don't like this option.
So, I after some researches, I found the solution I wanted: In the hooks git doc, I found a git config option which allows you to override your hooks folder. You can setup this option using the following command:
git config --global core.hookspath </your/hooks/folder>
This solved my problem!!!!!
But this solution is not the best for each situations. It works for me because I want to use my hooks in each repos I have. If I wanted to use this hooks only in some repos, it would not work. Or else, I would have to reset this property locally in the repos I want (which can be as boring as copying the hooks folder in each repos).
I hope you liked this short article, even if it is only about a git config option. Tell me that in comment!
It was Macdrien for Macnews, Good bye world.



