How to configure Git user name and email

· Category: Git

Short answer

Use git config to set your name and email so commits are properly attributed to you.

Steps

  1. Set globally:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
  1. Set per-repository:
git config user.name "Project Name"
git config user.email "[email protected]"
  1. Verify settings:
git config --list

Tips

  • Use the same email as your GitHub or GitLab account for proper linking.
  • Global config is stored in ~/.gitconfig.
  • Use --local explicitly for repository-specific settings.

Common issues

  • Commits showing wrong author: update the config and amend previous commits if needed.
  • Corporate environments may require specific email formats for compliance.