To change your git email setting, use the
git config command:
git config --global user.email "email@example.com" # Set a new email git config --global user.email # Verify the setting # firstname.lastname@example.org
The command takes two args:
- setting name:
- new email:
--global flag writes this setting into your global git config. If you remove that flag and run the command from within a repository, you will override the setting for that repository.
Make sure you've added the same email to your GitHub account settings. It may take some time for old commits to fall out of the server's cache, but new commits should link up immediately after pushing if the emails match.
git config user.email reports the correct value for the repository you're viewing, but new commits are using the wrong email, you may have environment variables set that are overriding the setting. Make sure you have not set the
This setting only affects future commits. To rewrite your old commits:
git filter-branchto rewrite the repository history (see this guide) and
- Force-push the new history up
Warning: It's considered bad practice to rewrite published history; you should only do this in an emergency. Simply add the email you've been using to your GitHub account and use that email going forward.