Motivation
I want to override my personal email address I use for Git with my work email address in my work directory without manually changing it each time.
Create a config file in the work directory
touch ~/path/to/work/directory/.gitconfig
# any customization/overrides can be added here [user] name = Clarice Bouwer email = clarice@example.com
Update ~/.gitconfig
[includeIf "gitdir:~/path/to/work/directory/"] path = ~/path/to/work/directory/.gitconfig
Verify
cd ~/ git config user.email # should be your default config email cd ~/path/to/work/directory git config user.email # should be your override email
Based on Stack Overflow: Set Git config values for all child folders and Alvin Alexander: Git show change username and email address.
Top comments (1)
This works great. Been using something similar for a while