https://git-scm.com/docs/git-config#_conditional_includes
Is a lot easier then what you came up with.
Re:Show HN: Switch Git Users CLI
by geongeorgek on Thursday November 12, 2020 @09:18AM
(#25070079)
Thanks. This is perfect but I also like the convenience of a quick switcher for any folder.
I find that creating a separate user account on my system for each client works much better for this kind of thing than trying to configure every application with multiple identities.
So I made this as a sugar for git config user.email [email protected]