GitHub uses the email address you set in your local Git configuration to associate commits with your GitHub account.

Setting your local Git email address using thegit configcommand

Thegit configcommand can be used to change your Git configuration settings, including your email address. It takes two arguments:

  • The setting you want to change--in this case,user.email.
  • Your new email address--for example,[email protected]. Be sure to use your own real, unique email address.

Your email address will be visible on commits to GitHub. If you'd like to keep your email address private, set your Git config email to[email protected]instead, replacingusernamewith your GitHub username. For more information, see"Keeping your email address private".

Setting your email address for every repository on your computer

  1. Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).

  2. Set your email address with the following command:

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

  3. Confirm that you have set your email address correctly with the following command.

    bash $ git config --global user.email # your\[email protected]

Setting your email address for a single repository

You may need to set a different email address for a single repository, such as a work email address for a work-related project.

  1. Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).

  2. Change the current working directory to the local repository in which you want to set your Git config email.

  3. Set your email address with the following command:

    bash $ git config user.email "your\[email protected]"

  4. Confirm that you have set your email address correctly with the following command.

    bash $ git config user.email # your\[email protected]

Setting your Git config email will not change the email address used for past commits, nor is it the same asadding your email address to your GitHub account.

Troubleshooting

Commits on GitHub aren't linking to my account

Make sure that the email address you set in your local Git configuration has beenadded to your GitHub account's email settings. After adding your email, commits that used that email address will automatically be counted in your contributions graph. There is no limit to the number of email addresses you can add to your account.

Changing your email address in your local Git configuration settings only affects commits that you make after that change. Old commits will still be associated with the old email address.

New commits aren't using the right email

Ifbashgit config user.emailreports the correct email address for the repository you're viewing, but your commits are using the wrong email address, your environment variables may be overriding your email address.

Make sure you have not set theGIT_COMMITTER_EMAILorGIT_AUTHOR_EMAILvariables. You can check their values with the following command:

bash $ echo $GIT\_COMMITTER\_EMAIL $ echo $GIT\_AUTHOR\_EMAIL

If you notice a different value, you can change it like so:

bash $ export GIT\_COMMITTER\_EMAIL=your\[email protected] $ export GIT\_AUTHOR\_EMAIL=<em>your\[email protected]

Hope you liked the Article.