fwiw you can avoid the configuration of the .ssh/config and hosts by just defining it in the custom included config as well and using the core.sshCommand variable. for example; i have:
# in my ~/.gitconfig
[includeIf "gitdir:~/dev/w/"]
path = ~/dev/w/work.gitconfig
and then
# in my "work.gitconfig" file
[core]
sshCommand = "ssh -i ~/.ssh/my_ed25519"
[user]
signingkey = ...
email = my@work.email
Thank you for sharing. I had no idea of the existence of the includeIf directive. Shamefully, I had resorted to just having no global user.name or user.email and setting it on a repo by repo basis. For me, just detecting by directory is plenty, as all of my work related code is within a directory of my companies name.
I saw someone over on HN who used includeIf to differentiate based on SSH identities, presumably by using a SSH Host entry, so both the SSH and Git identities are tied together.
fwiw you can avoid the configuration of the
.ssh/configand hosts by just defining it in the custom included config as well and using thecore.sshCommandvariable. for example; i have:and then
Thank you for sharing. I had no idea of the existence of the
includeIfdirective. Shamefully, I had resorted to just having no global user.name or user.email and setting it on a repo by repo basis. For me, just detecting by directory is plenty, as all of my work related code is within a directory of my companies name.I saw someone over on HN who used
includeIfto differentiate based on SSH identities, presumably by using a SSH Host entry, so both the SSH and Git identities are tied together.