Git: Setup Git for multiple emails

Programming, Technology


The common way we configure Git email address at our machine is:

git config --global

It’s only for 1 email address and it will become a challenge when you have 2 (or more) Git accounts for different purposes e.g: for work project and for personal project. Remote repository only calculates commit contribution if configured email address matches with account’s email address.

One of solution I think of is to re-configure email address by re-running above terminal command each time before committing. However, it seems not efficient. There is another way to solve it.