DEV Community

Discussion on: Utilizing GitHub accounts on Ubuntu with multiple SSH keys

Collapse
 
bojangles profile image
Bojangles

this article falls short. on newish versions of git you can use includeif to select which key to use based on directory.

[includeIf "gitdir:~/work/"]
    path = ~/.gitconfig.work

[includeIf "gitdir:~/code/"]
    path = ~/.gitconfig.personal
Enter fullscreen mode Exit fullscreen mode

then make a .gitconfig.personal file

[core]
sshCommand = "ssh -i ~/ssh/keys/personal"

[user]
email = joe@website.com
name = Joe 
Enter fullscreen mode Exit fullscreen mode