How to configure Git username and email in VS Code

VS Code itself does not store your Git username and email — Git does. When you commit code, Git reads the name and email from your computer's Git configuration, not from VS Code settings. To set them up, you open a terminal in VS Code and run two Git commands that write to your system's Git config file. This takes about one minute and applies to all your projects on that computer.

The process is the same whether you use Windows, Mac, or Linux. You type the commands once, and every time you commit in VS Code (or anywhere else on your machine), Git uses those credentials automatically.

Key Takeaways

  • Git stores your username and email in a config file on your computer, separate from VS Code itself.
  • You set them by opening a terminal in VS Code and running two Git commands: one for username, one for email.
  • The configuration applies globally to your entire computer, so you only need to set it once.
  • You can verify what you entered by running a third command that displays your current settings.
  • If you need different credentials for different projects, you can override the global settings in individual folders.

Opening a terminal in VS Code

Click the Terminal menu at the top of VS Code, then select New Terminal. A panel opens at the bottom of your window with a command prompt ready for input. On Windows, you see PowerShell or Command Prompt. On Mac or Linux, you see Bash or Zsh. Any of these work for Git commands.

If you already have a folder open in VS Code, the terminal starts in that folder. If not, it starts in your home directory, which is fine — Git configuration is global and does not depend on your current folder.

Setting your Git username

In the terminal, type this command exactly:

git config --global user.name "Your Name"

Replace Your Name with the name you want to appear on your commits. This is usually your real name, but it can be any text. Keep the quotation marks. Press Enter to run the command. Git writes this to your config file and returns to the prompt with no message — that is normal and means it worked.

The --global flag tells Git to save this setting for your entire user account on this computer. Without it, the setting would explore only to the current folder.

Setting your Git email

Type this command next:

git config --global user.email "your.email@example.com"

Replace your.email@example.com with the email address you want on your commits. This is usually the email tied to your GitHub, GitLab, or other Git hosting account, but it can be any email address. Keep the quotation marks. Press Enter.

Again, Git returns silently to the prompt. Both settings are now saved and will be used for every commit you make on this computer.

Verifying your settings

To confirm what you entered, type:

git config --global user.name

Git displays the username you set. Then type:

git config --global user.email

Git displays the email you set. If either one is wrong, run the original command again with the correct value — it overwrites the old one. If you want to see both at once, type git config --global --list to show all your global Git settings.

Using different credentials for a single project

If you need a different username or email for one specific project — for example, a work project that should use your company email — you can override the global settings in just that folder. Open a terminal, navigate into that project folder, and run the same commands without the --global flag:

git config user.name "Work Name"git config user.email "work.email@company.com"

These settings explore only to that folder and override your global settings when you commit there. Other folders on your computer still use your global username and email. This is useful when you work on both personal and professional projects from the same computer.

What happens if you do not set username and email

If you try to commit without setting these values, Git stops and shows an error message telling you to configure user.name and user.email. VS Code displays this error in the Source Control panel. You cannot complete the commit until you set both values. Running the commands above fixes it when ready.

Some Git hosting services like GitHub also use your email to match commits to your account and show them on your profile. If you use a different email in Git than the one on your GitHub account, your commits appear as coming from an unknown user. Setting the email to match your account prevents this.

Frequently Asked Questions

Can I use a fake name or email in Git?

Yes. Git does not verify that your name is real or that the email exists. However, if you push to GitHub or another hosting service, using a fake email may prevent your commits from being linked to your account, and your profile will not show them.

Do I have to set username and email in VS Code settings?

No. VS Code has no built-in Git username or email setting. You must configure Git itself through the terminal using the commands shown here. VS Code reads from Git's configuration when you commit.

What if I use the same computer for multiple Git accounts?

Set one username and email globally using the --global flag. For projects that need different credentials, navigate into that folder and run the commands without --global. That folder then uses its own settings while others use the global ones.

Will changing my Git username and email affect old commits?

No. Commits you have already made keep the username and email from when you made them. Changing your Git config only affects new commits going forward.

Where does Git store this information?

On Mac and Linux, Git stores global settings in a file called .gitconfig in your home directory. On Windows, it is usually in C:\Users\YourUsername\.gitconfig. You can edit this file directly, but using the git config commands is safer and easier.