How to Set Your Username and Email in Git Config |Video upload date:  · Duration: PT3M47S  · Language: EN

Quick guide to set user.name and user.email in Git config for global and repository level commits and to verify or fix author information

Why your Git identity matters

If your commits look like they were written by Mystery Committer then your git username and git email need help. Having correct user.name and user.email in git config makes your commits link to the right profile on hosting sites and keeps your version control history readable. Also it prevents your teammates from sending passive aggressive messages in team chat.

Quick global setup for the lazy but responsible

Want a default identity that applies to all projects on a machine Use the command line and set global values so new repositories inherit a sane author by default. This is the common pattern for dev machines and developer tools setup.

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

Per project identity when you need multiple hats

If you moonlight on open source or juggle work and side projects set local values inside the repo folder. Local settings take precedence over global settings so you can avoid accidental corporate commits on your weekend project.

cd path/to/repo
git config user.name "Project Name"
git config user.email "proj@example.com"

How to check what Git will actually use

Stop guessing and verify. The following commands show what git will stamp on new commits. These are part of every useful git tutorial for good reason.

  • git config --list shows all active configuration values
  • git config user.email shows the email that will be used in the current repo

Fixing a recent commit that used the wrong author

If the latest commit has the wrong author you can rewrite the most recent commit to correct the author field. This changes history so be ready to coordinate if the commit is already pushed.

git commit --amend --author="Correct Name "
# then push with history rewrite if needed
git push --force-with-lease

For multiple commits use interactive rebase to change author lines. Rewriting public history will annoy people so warn your collaborators before you rewrite the past.

Tips to avoid future identity chaos

  • Use a consistent git email that matches your hosting account to link commits to your profile
  • Keep global defaults and override at repository level for special cases
  • Automate developer tools setup with a script or dotfiles so every machine behaves the same

Wrap up

Setting user.name and user.email is a small command line chore that saves time and avoids embarrassing commit logs. Whether you are using git for hobby projects or as part of a larger team this is one of the foundational parts of version control hygiene. Now go fix that commit and pretend it was always right.

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.