How to use separate Git emails for work and personal use

You, how-togit
Back
  1. Create separate directories for work and personal use.
mkdir work
mkdir personal
  1. Create a Git config file per directory.
touch ~/.gitconfig-work
touch ~/.gitconfig-personal
  1. Update each config file with relevant details.
# ~/.gitconfig-work

[user]
    email = work@email.com
    name = Work Name
# ~/.gitconfig-personal

[user]
    email = personal@email.com
    name = Personal Name
  1. Update the global Git config file to use relevant config files per directory.
# ~/.gitconfig

[includeIf "gitdir:~/work/"]
    path = .gitconfig-work
[includeIf "gitdir:~/personal/"]
    path = .gitconfig-personal
© Josh Bochu.RSS