Git

How to Set Git Username and Email Address

Git is a popular distributed version control tool that is utilized to manage small to large projects in a good manner. In Git, users can set usernames and emails globally for the overall Git account and individually on the project repository. However, your username and email address can be different, which may be associated with your commits from your GitHub username and email.

This article will demonstrate:

So, let’s start!

How to Set Git Username and Email Address Globally?

Git usernames and emails are of two types, one is used for Git accounts globally, and the other is set on individual projects as per developers’ preference. To set a username and email, you can utilize the “$ git config –global user.name/user.email” command.

To set the Git username and email address globally, follow up on the below-provided step.

Step 1: Open Git Bash Terminal
Firstly, launch the Git Bash terminal from the Start menu:

Step 2: Set Username
Utilize the “git config” command with the “–global” option and add your first name and last name in the quotation:

$ git config --global user.name "Rafia Zafar"

Step 3: Set User’s Email Address
Similarly, set the user email using provided command:

$ git config --global user.email "[email protected]"

Step 4: Check Username and Email Configuration
To verify whether the username is set or not, utilize the “git config user.name” command:

$ git config user.name

Here, you can see we have successfully set the username:

To check whether the email address is saved or not, utilize similar command with the option “user.email”:

$ git config user.email

The below output indicates that the email address is saved:

How to Set Git Username and Email Address on Git Repository?

To set the Git username and email address on a specific Git repository or the project, check out the provided steps.

Step 1: Open Git Repository
First, open the Git repository where the project source code is placed or managed:

$ cd "C:\Git"

Step 2: Initialize Git Repository
Initialize the Git repository:

$ git init

Step 3: Set Username
Next, set the username with the help of the “git config user.name <Username>” command:

$ git config user.name "Jenny"

Step 4: Set User’s Email Address
Set the user email address using the same command and specify the email id with the “user.email” option:

$ git config user.email "[email protected]"

Step 5: Verify Username and Email is Set or not
To verify whether the username is set or not, check out the provided command:

$ git config user.name

The below-mentioned output shows that the username is set successfully:

To check whether the email is set or not, utilize the given command:

$ git config user.email

The email address is also set successfully:

Here you go! You have learned the procedure to set a Git username and email address.

Conclusion

To set the Git global username, the user can utilize the “git config –global user.name <F.name L.name>” command and set the email address through the “git config –global user.email <Email address>” command. In order to set a username and email address on a local repository or project, utilize the same command without using the “–global” option. This write-up has demonstrated the procedure to set a Git username and email address.

About the author

Rafia Zafar

I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.