1. 47
    1. 13

      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
      
      1. 5

        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.

        1. 2

          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.