Guide / Work email by folderStep 5 of 5 (optional)
Use your work email automatically in work folders
Keep all work repos in ~/work/, and Git uses your work email there by itself. This is Git's built-in includeIf: no tools, no aliases.
#1. Make the folder
mkdir -p ~/work#2. Create ~/.gitconfig-work
[user]
email = you@company.com#3. Add this to the end of ~/.gitconfig
[includeIf "gitdir:~/work/"]
path = ~/.gitconfig-workKeep the / at the end of ~/work/.
#Check
Inside any repo in ~/work/:
git config user.email
# you@company.comAnywhere else it prints your personal email.
More than two accounts? Add one folder, one
~/.gitconfig-<name>file and oneincludeIfblock per account.