Different git identity for work and personal projects

Stop committing to work repos with your personal email, automatically.

SNP 054 #1B3 Filed git

Keep your work projects in one folder and let git switch identities by path. In ~/.gitconfig:

ini
[user]
  name = Imre Csige
  email = [email protected]

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

And in ~/.gitconfig-work:

ini
[user]
  email = [email protected]
  signingkey = ~/.ssh/id_ed25519_work.pub

Every repository under ~/work/ picks up the work settings. Check which one is active with git config user.email inside a repo. The trailing slash in gitdir:~/work/ matters.