Recently, I ran into a situation that I need to use multiple git account on my laptop. Let say I have to work on multiple project and some of them I cannot use my public github profile. After gone through several approach, i found "conditional includes" of git config works quite well. Here's what you need to do.
Your global .gitconfig, for example
[user] name = Max Pijittum email = [email protected] [includeIf "gitdir:~/work/"] path = ~/work/.gitconfig
Work specific config ~/work/.gitconfig
[user] email = [email protected]
With this config, git will use different users on ~/work/ working tree, quite useful !
Git conditional include documentation: https://git-scm.com/docs/git-config#_conditional_includes