Crafting a masterpiece
Gradient background

How to use a different email address in Git in sub directories

Clarice Bouwer

Software Engineering Team Lead and Director of Cloudsure

Wednesday, 19 January 2022 · Estimated 1 minute read

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.

~/path/to/work/directory/.gitconfig
Copy
# any customization/overrides can be added here
[user]
        name = Clarice Bouwer
        email = clarice@example.com
        ```
~/.gitconfig
Copy
[includeIf "gitdir:~/path/to/work/directory/"]
    path = ~/path/to/work/directory/.gitconfig
Copy
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