⚠️ Warning ⚠️
This article was written 4 years and 2 months ago. The informations it contains may be outdated or no longer relevant.
In order to differentiate your professional and personal email address when working on git repositories, here is how I proceeded.
1. Create a global git hooks folder
Create a folder where you will drop the hooks that should apply to each repository.
And set the
core.hooksPath on this folder
git config --global core.hooksPath /path/to/my/centralized/hooks
2. Create a post-checkout hook
The hook post-checkout is triggered when you change branch, and also on the
git clone. So it'll be executed for existing repo, and those you will clone later.
post-checkout file below to see what I put in.
Don't forget to add execution permission on your new hook :
chmod +x post-checkout
⚠ The core.hooksPath support is new in Git version 2.9.