As of Git 2.13 git allows for Conditional Configurations.
This means that a specific set of configurations can be used based on certain conditions - such as executing git from a certain directory.

To separate my work and personal configs on my work machines, I simply keep all of my personal git projects under one root directory (typically ~/git/dev). Thus I can create a conditional configuration include to use my personal details (user.name, user.email, etc.) when executing git commands from all repositories located under ~/git/dev .

Default gitconfig

Create the default gitconfig under your home directory and add your usual work details.

~/.gitconfig

[user]
  name = Keith Patton
  email = <WORK_EMAIL>
[credential]
  helper = cache
[core]
  editor = vim
[color]
  ui = always

Personal gitconfig

Create a separate gitconfig and store your personal git details within it.

~/.gitconfig-personal

[user]
  name = Keith Patton
  email = <PERSONAL_EMAIL>
  username = <PERSONAL_USERNAME>

Conditional Configurations

Add the conditional configuration include to the beginning of your default gitconfig so as to pull in your personal gitconfig when git detects the specific personal root git directory.

~/.gitconfig

[includeIf "gitdir:~/git/dev/"]
  path = .gitconfig-personal
...
...
Tags