Introduction
Git offers three possibilities on how you can set your username
and email
. The settings will be considered in the following order, where 1. will always override 2. and 2. will override 3..
project
- The data is stored directly in the corresponding project(repository) under.git/config
.global
- for all repositories of the current user. The config file can be found in your home directory~/.gitconfig
.system
- This is a system wide configuration and is available for all users and all repositories. You will find it in/etc/gitconfig
.
In the most cases you will setup a global config for your user and additionally - if you work for example for different companies - you will also setup project specific configurations.
Set the username/email for a specific repository
git config user.name "Your project specific name"
git config user.email "your@project-specific-email.com"
Verify your settings:
git config --get user.name
git config --get user.email
Set the username/email globally
git config --global user.name "Your global username"
git config --global user.email "your@email.com"
Verify your settings:
git config --global --get user.name
git config --global --get user.email
Set the username/email system wide
This is a case which is usually not needed, but we will list it in any case.
git config --system user.name "Your default name"
git config --system user.email "your@system-email.com"
Verify your settings:
git config --system --get user.name
git config --system --get user.email