git
I. How To Set The user.email Property
Setting user.email For A Single Git Repository
The two commands shown below in examples 1.1 and 1.2 are equal in function to each other, and they have the same effect. The '--local' argument is optional; in the absence of the '--global' or the '--system' option then '--local' is implied.
Instructions
- Change your current working directory to the directory that contains the specific project you want to set user.email for. This can be done with the cd command.
- Run the command shown in example 1.1, replacing "john-doe@example.com" with your email address or whatever email address you want assigned to user.email for that project. You are not required to put double quotation marks around the email address but it is considered good practice to do so.
Example 1.1
Setting the user.email property for the specific project you are currently in.john@comp:~/mygitproject$ git config user.email "john-doe@example.com"
Example 1.2
Setting the user.email property for the specific project you are currently in; and being explicit about your intent by using the '--local' argument.john@comp:~/mygitproject$ git config user.email --local "john-doe@example.com"
Setting user.email For A Single Linux User
The command shown in example 2.1 will set the default email address for that specific Linux user. Other users on the same Linux machine will not be affected.
Example 1.3
Setting the user.email property for a single user.john@comp:~$ git config --global user.email "john-doe@example.com"
Setting user.email For All Linux Users
The command shown in example 3.1 will set the default email address for the entire system. This system wide value will be used if no project specific committer email address has been set, and if no user specific email address has been set.
Example 1.4
Setting the user.email property system wide.john@comp:~$ sudo git config --system user.email "john-doe@example.com"
Setting user.email Via An Environment Variable
If you wish to set the git commit email address via an environment variable then you can set the value of GIT_AUTHOR_EMAIL to your desired email address. GIT_AUTHOR_EMAIL has the highest precedence of all of the places where an email address can be obtained so by setting a value to GIT_AUTHOR_EMAIL you automatically override the value of user.email in all other configuration files in the git repository or the system on which you are operating.
Using the GIT_AUTHOR_EMAIL environment variable is useful for when you are scripting or automating git commits; or for setting user.email temporarily.
Example 1.5
Setting user.email via the environment variable GIT_AUTHOR_EMAILjohn@comp:~$ export GIT_AUTHOR_EMAIL='john-doe@example.com'
II. Ancillary Information
The examples provided on this page were generated on 2024-JULY-04 using the Linux based operating system Debian 12.6, with git installed via the apt-get package manager.
Documentation Last Updated: 2024-JULY-20 at 0227 PDT.
This document was last updated: