This doesn't work if you're using an agent like 1Password though and it doesn't handle signing commits with the right key either.
[includeIf "gitdir:~/work/client1/"]
path = ~/work/client1/.gitconfig
[includeIf "gitdir:~/work/client2/"]
path = ~/work/client2/.gitconfig
$ cat ~/work/client1/.gitconfig
[user]
email = emailforclient1
name = nameforclient1
signingKey = 3AA5C34371567BD2
[core]
sshCommand = ssh -i ~/.ssh/id_client1
$ cat ~/work/client2/.gitconfig
[user]
email = emailforclient2
name = nameforclient2
signingKey = 4BB6D45482678BE3
[core]
sshCommand = ssh -i ~/.ssh/id_client2
See:- https://news.ycombinator.com/item?id=36798978
- https://git-scm.com/docs/git-config#Documentation/git-config...