Working in a software house means changing projects from time to time. Usually, I have to use a separate git account for a new project. But I don't want to delete my original account, rather I'd like to have both. It's easy to solve, but surprisingly I see many people have problems with it. Here's the solution.
First of all, for each project/projects group add a custom .gitconfig
file - (/Projects/project/.gitconfig
) with desired git configuration:
[user]
name = Michal Lecicki
email = michal.lecicki@project.com
In another project, I could have a little different data:
[user]
name = Michal Lecicki
email = mlecicki@another_project.com
Finally, make a global git setup aware of additional configuration. Add to top-level .gitconfig
file:
[user] # my default settings
name = maikhel
email = maikhel@maikhel.pl
[includeIf "gitdir:~/Projects/project/"]
path = ~/Projects/project/.gitconfig
[includeIf "gitdir:~/Projects/another_project/"]
path = ~/Projects/another_project/.gitconfig
(...)
This way I make sure that my commits are signed with the correct email for each client. It helps to look professional and doesn't break Jira/Trello/other magic tool integration which identifies user actions by email.