Git

Git: Set user.name and user.email Globally

Git is a popular decentralized tracking tool used to manage development projects. When users start working on Git, they need to set the username and user email address for the account first. Then, they can access the GitHub repositories. More specifically, Git users can set the username and email address in two ways. To set the username and email address globally for Git accounts and locally for each repository.

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:

$ cd "C:\Users\nazma\Git"

Step 2: View Configured User Name

Then, view the default configure user name by executing the “git config” command:

$ git config --global user.name

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:

$ git config --global user.name "Maria"

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:

$ git config --global user.name

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:

$ git config --global 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:

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

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:

$ git config --global user.email

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.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.