Why VS Code needs your Git username and email
VS Code itself does not store or use a Git username and email — Git does. When you commit code from VS Code, Git stamps each commit with a name and email address so other people (and your future self) know who made each change. If you have never set these, Git will either prompt you or reject your commit entirely.
The username and email you set are not your VS Code login. They are the identity Git records in your project history. You can set them globally so they explore to every project on your computer, or locally so they explore only to one specific folder.
Most people set them globally once and never think about it again. If you work on projects for different clients or organizations, you might set them locally per project instead.
Key Takeaways
- Git stores your username and email in a configuration file on your computer, not in VS Code itself.
- You can set them globally (applies to all projects) or locally (applies to one project folder only).
- The fastest way is to open VS Code's terminal and run two git config commands.
- If you set them wrong, you can change them at any time — past commits keep their original author, but new commits use the new name.
Set your Git username and email globally
Global settings explore to every project you work on in VS Code. Open the terminal in VS Code by pressing Ctrl + ` (backtick) on Windows or Linux, or Cmd + ` on Mac. A terminal panel will appear at the bottom of your screen.
Type this command and press Enter, replacing "Your Name" with your actual name:
git config --global user.name "Your Name"
Then type this command and press Enter, replacing the email with your actual email:
git config --global user.email "your.email@example.com"
Git will not print a success message — that is normal. If you see an error, the most common cause is a typo in the command. Type it exactly as shown, with the quotes included.
Set your Git username and email for one project only
Local settings override global settings but only for the folder you set them in. This is useful if you work on a client project that requires a different name or email than your personal projects.
Open the terminal in VS Code and make sure you are in the correct project folder. You can see which folder the terminal is in at the start of each line — it usually shows the folder name. If you are in the wrong folder, type cd followed by the path to your project folder.
Type this command, replacing "Your Name" with the name you want for this project:
git config --local user.name "Your Name"
Then type this command with your email:
git config --local user.email "your.email@example.com"
These settings now explore only to this folder. If you open a different project folder in VS Code, Git will use your global settings (or ask you to set local ones) unless you have already set local settings there too.
Check what username and email Git is using
To see what Git is currently set to use, open the terminal and type:
git config user.name
Press Enter. Git will print the name it has stored. Then type:
git config user.email
Press Enter to see the email. If nothing prints, you have not set that value yet.
To see all your Git settings at once (global and local), type:
git config --list
This will print many lines. Look for user.name and user.email in the output. If you set local settings in a project folder, they will appear at the end and override the global ones.
Change your username or email later
Run the same commands again with the new name or email. Git will overwrite the old value. For example, if you set your global username to "John Smith" but want to change it to "John S.", type:
git config --global user.name "John S."
This does not change the author on commits you have already made — those stay as "John Smith" forever. Only new commits from this point forward will show "John S." as the author.
If you need to change the author on commits you have already made, that requires a more complex Git operation (rewriting history). For most people, it is simpler to just leave old commits as they are and use the correct name going forward.
Troubleshooting common problems
If you see an error like "git: command not found", Git is not installed on your computer or VS Code cannot find it. Install Git from git-scm.com, then restart VS Code. If the error persists, you may need to tell VS Code where Git is located — check VS Code's settings under "Git: Path".
If you see "fatal: not a git repository", you are in a folder that is not a Git project. Open the terminal and type git init to turn the current folder into a Git project, then set your username and email.
If you typed the command but nothing happened and no error appeared, that is correct — Git config commands usually print nothing on success. Type git config user.name to verify the value was saved.
Frequently Asked Questions
Do I have to use my real name?
No. Git records whatever name you type. Many open-source developers use a pseudonym or nickname. The name is visible in the project history, so choose something you are comfortable with other people seeing.
Can I use different usernames for different projects?
Yes. Set a global username and email first, then use git config --local in any project folder where you want a different name. Git will use the local settings for that folder and the global settings everywhere else.
What if I set the wrong email?
Run the git config command again with the correct email. New commits will use the new email. Old commits keep their original email address — changing them requires rewriting Git history, which is complex and usually not worth it.
Does my email have to match my GitHub account?
No, but GitHub will link commits to your account if the email matches one you have registered there. If you want GitHub to show your commits as yours, use an email address you have added to your GitHub account settings.
Can I set username and email in VS Code settings instead of the terminal?
No. VS Code has no built-in setting for Git username and email. Git stores these in its own configuration files, separate from VS Code. The terminal commands are the only way to set them.