How to Set the Git Email Property in Git Config |Video upload date:  · Duration: PT4M11S  · Language: EN

Quick guide to set Git user email using git config for global and local scopes and fix commit author issues on repositories

If your commits look like they came from a witness protection program it is usually because git does not have the right email for your commits. This guide shows how to check set and fix your git user email so commits show up under the identity you actually want on GitHub and other hosts.

Check the email git will use

Want to know what email new commits will carry? Run these inside a repo to see local and global values

git config user.email
git config --global user.email

If the first command prints nothing git falls back to the global value. If both are empty your commits might look annoyingly anonymous.

Set a global email for the whole machine

The global setting applies to every repository on this machine unless a repo overrides it. Great for a personal laptop where you do 90 percent of your life

git config --global user.email "you@example.com"

Set a repository specific email

Need a separate work identity for that corporate repo? Set the email while inside the project folder and only that repo will use it

git config user.email "you@work.com"

Verify your settings

Do not trust hope or a hunch. Confirm what changed with these commands

  • git config --global --list to see global entries
  • git config --local --list to see repo level entries
  • git config --list to see the effective values

Fix past commits if the blame game is on

To correct the most recent commit without changing the message run

git commit --amend --author="Your Name " --no-edit

To edit many commits use an interactive rebase and rewrite the author information for the affected commits

git rebase -i HEAD~N

There are also history rewrite tools for bulk changes. Warning rewriting published history can frustrate collaborators and cause merge drama Do not rewrite shared branches without coordinating first.

Quick tips to avoid future identity drama

  • Use the same email you registered with GitHub or GitLab so commits link to your profile
  • Use global for personal machines and repo level settings for project specific identities
  • Verify settings before pushing after any history rewrite

That covers checking setting verifying and repairing git email values. Now go commit like the professional you pretend to be.

I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!

This is a dedicated watch page for a single video.