Setting your email in Git
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 config
command
Thegit config
command 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,
your_email@example.com
. 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 tousername@users.noreply.github.com
instead, replacingusername
with your GitHub username. For more information, see"Keeping your email address private".
Setting your email address for every repository on your computer
Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).
Set your email address with the following command:
bash $ git config --global user.email "your\_email@example.com"
Confirm that you have set your email address correctly with the following command.
bash $ git config --global user.email # your\_email@example.com
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.
Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).
Change the current working directory to the local repository in which you want to set your Git config email.
Set your email address with the following command:
bash $ git config user.email "your\_email@example.com"
Confirm that you have set your email address correctly with the following command.
bash $ git config user.email # your\_email@example.com
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.email
reports 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_EMAIL
orGIT_AUTHOR_EMAIL
variables. 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@example.com $ export GIT\_AUTHOR\_EMAIL=<em>your\_email@example.com
Hope you liked the Article.