Can I specify multiple users for myself in .gitconfig?

Since git 2.13, it is possible to solve this using newly introduced Conditional includes.

An example:

Global config ~/.gitconfig

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

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

Work specific config ~/work/.gitconfig

[user]
    email = [email protected]

Remember that [includeIf...] should follows default [user] at the top.


Or you can add following information in your local .git/config file

[user]  
    name = Your Name
    email = [email protected]

You can configure an individual repo to use a specific user / email address which overrides the global configuration. From the root of the repo, run

git config user.name "Your Name Here"
git config user.email [email protected]

whereas the default user / email is configured in your ~/.gitconfig

git config --global user.name "Your Name Here"
git config --global user.email [email protected]

Tags:

Git

Git Config