Fix: "Make sure you configure your 'user.name' and 'user.email' in Git" (VS Code Error)
If you're trying to commit your code in VS Code and suddenly see this error:
"Make sure you configure your 'user.name' and 'user.email' in git"
Don’t worry — this is a very common issue, especially if you're setting up Git for the first time or using a new system.
Let’s see what this error means and how to fix it.
Git commit error in VS Code showing user.name and user.email are not set
What This Error Actually Means
Git needs to know who is making the changes.
Every commit in Git includes:
- Your name
- Your email address
If you haven’t configured these details yet, Git will block you from committing — and that’s exactly why you’re seeing this error.
Why This Happens
1. Fresh Git Installation
If you just installed Git, it doesn’t have your identity configured yet.
2. New System / New Machine
Git configuration is stored locally. So switching systems means you need to set it again.
3. VS Code Using Git Without Config
VS Code depends on Git settings. If Git is not configured, commits fail.
How to Fix It (Step-by-Step)
Step 1: Open Terminal
You can use:
- VS Code Terminal
- Command Prompt
- Git Bash
Step 2: Set Your Name (Global)
# Set your Git username for all projects
git config --global user.name "Your Name"
Example:
git config --global user.name "Selva Raj"
Step 3: Set Your Email (Global)
# Set your Git email for all projects
git config --global user.email "your@email.com"
Example:
git config --global user.email "selva@example.com"
Step 4: Verify Configuration
# Check configured values
git config --global --list
You should see:
user.name=Selva Raj
user.email=selva@example.com
Step 5: Try Commit Again
# Add files
git add .
# Commit changes
git commit -m "Initial commit"
Now it should work without any errors.
Local vs Global Configuration (Simple Explanation)
This is where many beginners get confused, so let me explain it in a simple way.
Global Configuration (One-time Setup)
This applies to all projects on your system.
# Set once, works everywhere
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
Use this when:
- You are working on personal projects
- You use the same identity everywhere
Local Configuration (Project-Specific)
Local config means you set a different name or email for a specific project only.
This is very useful if:
- You work for a company and need a work email
- You manage multiple clients/projects
Step-by-step (Local Config)
# Step 1: Go inside your project folder
cd your-project-folder
# Step 2: Set project-specific name
git config user.name "Work Name"
# Step 3: Set project-specific email
git config user.email "work@email.com"
Important: Notice there is NO --global here.
This means:
- Only this project will use this name/email
- Other projects will still use your global config
Check Local Config
# Check only current project config
git config --list
Real-Life Example (Easy to Understand)
Think of it like this:
- Global config = your personal identity (used everywhere)
- Local config = your office ID card (used only in one company)
So if you're working on:
- Personal GitHub → use global
- Company project → use local
Common Mistakes to Avoid
- Forgot to use
--global, so it works only in one project - Used
--globalby mistake, so it affects all projects - Using wrong email (especially for GitHub commits)
- Running commands outside your project folder for local config
Quick Tip for GitHub Users
If you're using GitHub, make sure your email matches your GitHub account email.
Otherwise, your commits may not show up in your contributions graph.
Conclusion
This error is actually helpful — Git is just asking, “Who are you?” before saving your work.
Once you set your username and email, you're good to go.
Use:
- Global config → for general use
- Local config → for specific projects
It’s a simple one-time setup, but it’s essential for proper version control.
FAQ
1. Do I need to configure Git every time?
No. Global config is a one-time setup.
2. Can I use different emails for different projects?
Yes, that’s exactly what local config is for.
3. What happens if I don’t configure Git?
You won’t be able to commit changes.
4. Can I change my Git username later?
Yes, just run the same command again with a new value.
5. Is this a VS Code problem?
No. This is a Git configuration issue — VS Code is just showing it.
That’s it. Simple fix, but very important.
If you're just starting with Git, this is one of the first things you should always set up.