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 "your@email.com"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 user.email=sabbir@example.comIf you haven’t set one yet (or want to change), use:
git config --global user.name "Your Name"
git config --global user.email "your@email.com"git config user.name "Your Work Name"
git config user.email "work@example.com"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
user.email=enam@example.com
core.editor=vim
color.ui=autoIf you want to hide your real email from public commits, GitHub gives you a no-reply address:
12345678+username@users.noreply.github.comYou 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 "12345678+username@users.noreply.github.com"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 "sabbir@personalmail.com" git config user.name "Sabir (Work)"
git config user.email "sabir@company.com" 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 "12345+username@users.noreply.github.com" | 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.

Shadows disappearing in your Threlte or Three.js scene? It’s a frustum issue. Learn how to visualize the shadow box and fix clipping instantly with this guide.

What happens when you create a DocType in Frappe? We break down the .json, .js, and .py files generated by the framework and how to use them.

Confused by Shopify's lack of a database? 🤯 Learn how Shopify stores your theme data, from simple Settings to complex Metafields. Perfect for devs moving from WP/Laravel.