How to Set Git Username & Email Config (Global & Local)


If you just want the quick fix — here it is:
# Check config
git config --list
# Check your global Git config
git config --global user.name
git config --global user.email
# Set or update them
git config --global user.name "Your Name"
git config --global user.email "[email protected]"Done ✅ — you’ve now set your Git identity globally for all projects. Now, let’s break it down properly for those who like to understand what’s really happening under the hood.
When you commit to a Git repository, Git records who made that change. It does this using two simple pieces of info:
Every commit you make is stamped with this info — it’s your digital signature inside Git.
You can check your Git configuration in three scopes:
git config --global user.name
git config --global user.emailThis is stored in:
~/.gitconfigIf you’re inside a project folder:
git config user.name
git config user.emailThis one is stored inside your project’s .git/config.
To see all your configs (and where they come from):
git config --show-origin --listExample output:
file:/home/sab/.gitconfig user.name=Sabir Hasan
file:/home/sab/.gitconfig [email protected]If you haven’t set one yet (or want to change), use:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"git config user.name "Your Work Name"
git config user.email "[email protected]"This is great when you use different GitHub accounts — e.g., one for work, one for personal projects.
To double-check:
git config --listExample:
user.name=Enam Hasan
[email protected]
core.editor=vim
color.ui=autoIf you want to hide your real email from public commits, GitHub gives you a no-reply address:
[email protected]You can find it in your GitHub settings under Settings → Emails → “Keep my email addresses private”
Then just use it like this:
git config --global user.email "[email protected]"This keeps your commits verified while keeping your real email hidden.
If you switch between personal and work GitHub accounts:
git config --global user.name "Sabir Hasan"
git config --global user.email "[email protected]" git config user.name "Sabir (Work)"
git config user.email "[email protected]" Git will automatically use the local one when you’re inside your work repo.
| Task | Command | Scope |
|---|---|---|
| Check username & email | git config user.name / git config user.email | Local |
| Check global config | git config --global user.name / git config --global user.email | Global |
| Set username & email | git config --global user.name "Your Name" | Global |
| Hide email using GitHub no-reply | git config --global user.email "[email protected]" | Global |
Knowing how to check and set your Git config properly saves you from those “mystery commits” that show the wrong name or email. It’s one of those small hygiene habits that make your GitHub history clean, traceable, and professional.
So next time you open a new repo and push your first commit — make sure it’s signed with you.

Stop fighting Git permissions in WSL. This post explains the root cause of the 'Permission Denied' error and shows you the permanent fix.

Learn why the Frappe framework's built-in reporting is a game-changer. See how to customize, group, and save reports instantly

Discover PostgreSQL’s origins, unique features, and how it stacks up against MySQL and MariaDB. Perfect for beginners learning modern database systems.