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
- Set globally:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
- Set per-repository:
git config user.name "Project Name"
git config user.email "[email protected]"
- 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
--localexplicitly 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.