Git

How to Change Email Address in Git?

On Git, when developers make commits after adding changes in the projects on the Git local system, they may want to push into the GitHub hosting service as the commit data decides which user account to attach to the push. In such a situation, developers need to save the user email during the configuration. Additionally, they can change the new user email address with the previous one.

This blog describes:

How to Change Email Address in Git Globally?

If developers want to change the email address accessible for all users available on Git repositories, they need to configure the user email address globally. To change the email address in Git globally, follow the instructions step by step.

Step 1: Check Existing User Email

First, check the existing globally saved user email through the “git config” command along with the “–global” option and “user.name”:

$ git config --global user.email

It can be observed that the configured user mail is displayed as the output:

Step 2: Change Email Address

Now, execute the “git config” command with the “–global” option along with the new user email address:

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

Step 3: Verify Newly Added Email

Lastly, verify the newly added or configured email address:

$ git config --global user.email

According to the below-provided output, the existing email is changed with the newly added email address:

Let’s have a quick look at the next section to learn how to change the email address in Git locally.

How to Change Email Address in Git Locally?

Local email addresses can be accessible for specific repository users. Follow the steps to save or change the new user email address.

Step 1: Check Existing User Email

To check the already configured saved user email address, run the following command:

$ git config user.email

Step 2: Change Email Address

Now, execute the “git config” command with the new email address:

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

Step 3: Ensure Added Email

Lastly, execute the “git config” command to ensure the configured email address:

$ git config user.email

It can be seen that the local email address has been changed successfully:

That’s all! We have provided the method to change the email address in Git globally and locally.

Conclusion

The globally changed user email is accessible for all repositories in the Git root directory. In contrast, the locally saved user email can be permitted for specific repositories. To change the user email globally, the “$ git config –global user.email <email-address>” command and to change the user email locally, the “$ git config –global user.email <email-address>” command can be utilized. This post demonstrated the procedure to change the user email addresses globally and locally.

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.