Multiple Accounts and Git

Written by / Original link on Sep. 2, 2021


If you have multiple accounts that you must use with Git — such as a personal and a work account — you can have your Git Config (typically ~/.gitconfig) conditionally include other configs depending on the folder you’re working in. In those extra configs you then can override some settings.

Here’s an example ~/.gitconfig that has two dynamic includes:

  name = "John Doe"

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

[includeIf "gitdir:~/repos/work/"]
  path = ~/

Inside each ~/.gitconfig.XXX you can then list extra config values, here the email address to use for each:

  email =

💡 If you want to use individual SSH keys for each account, there’s some more steps you need to take.

bram accounts taylorotwell taylorotwell bram

« MIDI controller to PS/2 - part 1 [blog] - Random Paint Effects with Houdini »