Managing Multiple Github Profiles

Many folks might be using same laptop while working on work and hobby projects. using git config on every repo to set email and username might not be feasible when you have multiple hobby projects.

In those cases, we can make use of conditional includes of git and it’s supported from git 2.13 onwards.

Gobal git config:

[user]
    name = John Doe
    email = [email protected]

[includeIf "gitdir:~/work/"]
    path = ~/work/.gitconfig

Add .gitconfig file in your work directory where you are keeping all the work related projects and add a different email id

[user]
    name = John Doe
    email = [email protected]

Happy coding!