A little known feature of Git is that you can have conditions, for instance, to have a work and personal name and email.
First, the ~/.gitconfig
file:
[includeIf "gitdir:~/src/personal/"]
path = ~/.gitconfig.personal
[includeIf "gitdir:~/src/work/"]
path = ~/.gitconfig.work
Code language: PHP (php)
After specifying this, you can then create two files, ~/.gitconfig.personal
and ~/.gitconfig.work
, containing:
[user]
email = email@something.com
name = MyName
and
[user]
email = jae@consoso.com
name = Very serious business person
Now, when you are in ~/src/personal/
, the personal email and name will be used, and when in ~/src/work/
, the work one will be.