DEV Community

Cover image for Git user config per path
João Vitor
João Vitor

Posted on

Git user config per path

TIL git config core.sshCommand

TIL here that git provides a config for core.sshCommand.

I was already splitting my personal and work git user configuration by path with this setting in my ~/.gitconfig.

So adding the block below simplified my .ssh/config and my cloning/pushing.

[core]
       sshCommand = "ssh -i ~/.ssh/id_ed25519_personal -F /dev/null"
Enter fullscreen mode Exit fullscreen mode

~/.gitconfig

[include]
    path = ~/dotfiles/gituser_work.include
[includeIf "gitdir/i:~/dotfiles/"]
    path = ~/dotfiles/gituser_personal.include
Enter fullscreen mode Exit fullscreen mode

gituser_work.include

[user]
       name = Your Full Name
       email = your@work-email.com
Enter fullscreen mode Exit fullscreen mode

gituser_personal.include

[user]
       name = Your Full Name
       email = your@personal-email.com

[core]
       sshCommand = "ssh -i ~/.ssh/id_ed25519_personal -F /dev/null"
Enter fullscreen mode Exit fullscreen mode

Top comments (0)