git

Git user config per path

joaovitor

João Vitor

Posted on June 22, 2021

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
💖 💪 🙅 🚩
joaovitor
João Vitor

Posted on June 22, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related