Phil for Humanity Phil for Humanity
A Guide for the Survival of Humankind and Helping the World, Society, and Yourself.

How to Configure Global Git Hooks

Each time a Git user clones or creates a repository, the user must manually copy their Git hooks into the ".git/hooks/" directory of each repository. This is a very manual process that can easily be done incorrectly or completely forgotten altogether.

If you want to never have to do this again on your computer, then you can setup global Git hooks for all repositories on a single computer.

First, you need to decide on a templates directory where your global Git hooks will reside. You can use the existing example templates directory at:


I recommend that you use this existing example templates directory, or you can create a new templates directory anywhere you want. In this templates directory, create a sub-directory called "hooks" if it does not exist, such as:


Second, copy all the Git hooks that you want to become global into this templates "hooks" directory.

Third, configure your computer to know that this templates directory exists using this command:

git config --global init.templatedir '<GIT_TEMPLATES_DIRECTORY>'

Finally, you need to know how these global Git hooks become activated. From now on whenever you create a new repository or clone another repository, Git will copy all the global Git hooks from the templates hooks directory to the repository's local hooks directory located at:


For all existing repostories on your computer, you must run the "git init" command to copy the global Git hooks to the repository's local hooks directory while in each repository's root diretory.

Remember, global Git hooks are only configured for newly created and cloned repositories. So each time that you modify, add, or delete a global Git hook, you must manually re-config all existing repositories.

In my opinion, there is a huge room for improvements with global Git hooks. First, I would prefer a global hooks directory without the need to re-initialize each repository. Updating a hook in this global hooks directory would immediately affect each repository on the computer. Second, I would also like to be push Git hooks into the repositories to force all users to run certain mandatory hooks.

by Phil for Humanity
on 20120424

Related Articles
 » Why We Must Act to Prevent Global Warming
 » Volcanoes versus Global Warming
 » To All Global Warming Deniers