Different Configurations for Git depending on the Workspace Folder
Sometimes you want to use different emails or GPG keys for your git projects (e.g., separating work and private projects). For this, you can use the includeIf directive in your .gitconfig.
Implementation
If all your projects are under ~/workspace but you want specific settings for ~/workspace/acme/*, use this setup:
File: ~/.gitconfig
[user]
email = mike@example.com
name = Mike
signingkey = 123ABCDEF456
[includeIf "gitdir:~/workspace/acme/"]
path = .gitconfig-acme
File: ~/.gitconfig-acme
[user]
email = mike@acme.com
name = Mike Petersen
signingkey = 789ABCDEF456
[commit]
gpgsign = true
