I found this user management strategy somewhere, and it's been working great for me: git config --global --unset user.name git config --global --unset user.email git config --global --unset user.signingkey git config --global user.useConfigOnly true git config --global user. .name " " git config --global user. .email " " git config --global alias.identity '! git config user.name "$(git config user.$1.name)"; git conf…
I find it much easier to use direnv and set GIT_AUTHOR_EMAIL in each of ~/work/.envrc and ~/personal/.envrc No need to reconfigure every repo this way.
On ~/.gitconfig
[user]
name = personal
email = personal@example.com
[includeIF "gitdir:~/workspace/"]
path = ~/work.gitconfig
Then on ~/work.gitconfig [user]
name = workname
email = work@example.com
[1] https://git-scm.com/docs/git-config#_conditional_includes