Some times we need to use different git profiles to have meaningful commits signatures when we need to use work profiles or personal profiles.
You can do this if you use
git >= 2.13 with the rule
includeIf you can choose when to use a particular profile when
you are on a specific folder or subfolders.
To do that you need to modify the file
~/.gitconfig with this content:
[user] name = Your Name email = email@example.com [includeIf "gitdir:~/Projects/Work/"] path = ~/.gitconfig-work
And you should have a file like
~/.gitconfig-work (for this example) with this content:
[user] name = Your Name email = firstname.lastname@example.org
You can add as many
includeIf as you need.
So now if you cd to any git project inside
~/Projects/Work your git config should be like this:
~ $ git config user.email email@example.com ~ $ cd ~/Projects/Work/some-project ~/Projects/Work/some-project $ git config user.email firstname.lastname@example.org ~/Projects/Work/some-project $ cd ~/Projects/personal-website /Projects/personal-website $ git config user.email email@example.com