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 .
Create the default gitconfig under your home directory and add your usual work details.
[user] name = Keith Patton email = <WORK_EMAIL> [credential] helper = cache [core] editor = vim [color] ui = always
Create a separate gitconfig and store your personal git details within it.
[user] name = Keith Patton email = <PERSONAL_EMAIL> username = <PERSONAL_USERNAME>
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.
[includeIf "gitdir:~/git/dev/"] path = .gitconfig-personal ... ...