Embracing the Messiness in Search of Epic Solutions

Git: Configuring Different Git User Info Depending on Projects




Given, the following global config stored under ~/.gitconfig

    name = Shitty Developer
    email = [email protected]

When committing any code, the above user info will always be used.

However, there are times you want to use a different user info depending on projects (ex: work projects, GitHub projects, etc)


This is one of many ways to solve this problem.

Let’s assume [email protected] configured in ~/.gitconfig is reserved for work-related projects.

To set up a different user email for GitHub projects, modify ~/.gitconfig with the following configuration:-

    name = Shitty Developer
    email = [email protected]

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

Under ~/github/.gitconfig, add your GitHub user account’s email:-

    email = [email protected]

If the checked out project resides under ~/github/ directory, any committed code will now use [email protected] instead of [email protected].



Leave a Reply