This article will demonstrate:
- How to set Git Username and Email address Globally?
- How to set Git Username and Email on Git Repository?
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:
Step 3: Set User’s Email Address
Similarly, set the user email using provided command:
Step 4: Check Username and Email Configuration
To verify whether the username is set or not, utilize the “git config user.name” command:
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”:
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:
Step 2: Initialize Git Repository
Initialize the Git repository:
Step 3: Set Username
Next, set the username with the help of the “git config user.name <Username>” command:
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:
Step 5: Verify Username and Email is Set or not
To verify whether the username is set or not, check out the provided command:
The below-mentioned output shows that the username is set successfully:
To check whether the email is set or not, utilize the given command:
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.