“git config email” Tutorial

Now we have installed the git into our system and we want to start coding immediately. But wait a minute there are some basic tasks which are very helpful to use git. The git config email command is used to configure the git email address for the current installation and developer. This email configuration is stored in different places but the most popular location is ~/.gitconfig for the current user.

List Current Email Address

The current email address can be listed by ng the git config --list command like below.

$ git config --list

We can only list the email address and omit other configuration lines by grepping email addresses like below.

$ git config --list | grep email

Set Email Address with “git config email” Command

The email address for the current user can be set by using the git config user.email command. In the following example, we set the email address as ibaydan@wisetut.com .

$ git config user.email "ibaydan@wisetut.com"

Set Email Address Manually for Current User

The email address of the current user can be also set by editing the ~/.gitconfig file manually. The email configuration is located under the [user] section. Just use the following configuration lines to email the current user.

[user]
   email = ibaydan@wisetut.com

Set Email Address Manually for Globally (Whole System)

By default, the email address for the current user is set for only the current user and session. We can also set the email address globally or for the whole system by using the git config --global user.email command like below.

$ git config --global user.email "ibaydan@wisetut.com"

Set Email Using Environment Variables

Another way to set email address is using GIT_COMMITTER_EMAIL and GIT_AUTHOR_EMAIL environment variables. Just put the following lines to your shell to set email address.

GIT_COMMITTER_EMAIL=ibaydan@wisetut.com
GIT_AUTHOR_EMAIL=ibaydan@wisetut.com

To make email environment variable persistent and useable between reboots. Put lines above inside the ~/.profile or ~/.bashrc files.

Leave a Comment