This blog will explain:
How to Set user.name Globally on Git?
To set the user.name globally on Git, first, move to the Git root directory and check the list of the configured username. Then, run the “git config –global user.<name>” command.
Step 1: Go to Git Root Directory
First, navigate to the Git root directory by providing its path with the “cd” command:
Step 2: View Configured User Name
Then, view the default configure user name by executing the “git config” command:
Here, the “–global” option is used to show the specific repository username:
It can be observed that currently, the username is not set globally.
Step 3: Set User Name Globally
Now, add the desired username for each repository individually by running the provided command:
In the above-listed command, we have specified “Maria” as a new username:
Step 4: Verify Set Username
To ensure whether the specified username is added or not, use the following command:
As you can see, the specified username has been set globally:
How to Set user.email Address Globally on Git?
To add the user.name globally on Git, follow the below-given procedure.
Step 1: View Default User Email
First, run the “git config” command to view the default user.email:
According to the below-given output, the global user email is not added yet in the configuration file:
Step 2: Add User Email Address Globally
Then, set the user email address by running the below-stated command:
Here, we have provided “[email protected]” as the user email address:
Step 3: Verify Added User Email address
Lastly, verify the provided user email address through the “git config” command:
It can be observed that the specified email address has been added successfully:
That’s all! We have explained the method to set the user.name and user.email globally.
Conclusion
To set the username and email address, first, move to the Git root directory and then check the default value of the username and email address. After that, execute the “git config –global user.<name>\email” command to add the username and email address to the Git account. This blog illustrated the process of adding a username and email address globally.