How to Set Up Git in VS Code and Configure Your Name and Email

Set up Git in VS Code by installing Git, configuring your name and email, and verifying the setup. VS Code uses your machine's Git installation and picks up your global config automatically.

5 min read

VS Code uses the Git installation on your machine. It does not bundle its own copy of Git. To set up Git in VS Code, you need Git installed and your name and email configured so Git knows who is making each commit.

Once Git is ready, learn how to /vscode/how-to-sign-in-to-github-from-vs-code and /vscode/how-to-initialize-a-git-repository-and-publish-it-to-github-from-vs-code.

Install Git

VS Code requires Git version 2.0.0 or later. If you already have Git installed, skip to the next section.

PlatformRecommended method
WindowsDownload the installer from git-scm.com. Run it and accept the defaults. Git Bash is included.
macOSRun brew install git if you have Homebrew, or download the installer from git-scm.com.
LinuxUse your package manager: sudo apt install git (Ubuntu/Debian), sudo dnf install git (Fedora), or sudo pacman -S git (Arch).

After installing, open a terminal and run this command to confirm the version:

bashbash
git --version

You should see something like git version 2.47.0 or later.

If you installed Git while VS Code was already open, restart VS Code. The editor checks for Git at startup and enables source control features only when it detects a working installation.

Configure your name and email

Git attaches a name and email address to every commit. You only need to set these once per machine. Open a terminal (any terminal works: the VS Code integrated terminal, your system terminal, or Git Bash on Windows) and run:

bashbash
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

Replace "Your Name" with the name you want on your commits and "your.email@example.com" with your actual email address.

The --global flag writes these values to your global Git configuration file (~/.gitconfig on macOS and Linux, C:\Users\YourName.gitconfig on Windows). VS Code reads this file automatically.

Verify the configuration

To confirm Git is properly set up in VS Code:

Open VS Code

If you just installed Git, restart VS Code first.

Look at the Activity Bar

The Source Control icon (a branch symbol) appears on the left Activity Bar. If you see it, VS Code detected Git.

Open a folder

Open any folder with File > Open Folder. If the folder is not a Git repository yet, the Source Control view shows a button to initialize one.

Check your config

Open the integrated terminal with Ctrl+** (Windows/Linux) or **Cmd+ (macOS) and run:

bashbash
git config --global --list

Your configured user.name and user.email should appear in the output.

Use a different identity per repository

Your global name and email apply to every repository on your machine. If you need a different identity for a specific project (for example, a work email for a work repository), open that project in VS Code and run these commands in the integrated terminal without --global:

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

This writes the values to the repository's local .git/config file. The local config overrides the global config for that repository only. VS Code honors both layers automatically.

What if VS Code does not detect Git?

If the Source Control icon does not appear in the Activity Bar after installing Git and restarting VS Code, try these checks:

  • Open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P) and run Git: Show Git Output. This opens a log that often explains the problem.
  • Make sure Git is on your system PATH. Run git --version in your system terminal. If it works there but not in VS Code, you may need to restart VS Code or configure the git.path setting.
  • Check the git.path setting if VS Code cannot find Git automatically. Open Settings (Ctrl+, / Cmd+,), search for git.path, and enter the full path to the Git executable (for example, C:\Program Files\Git\bin\git.exe on Windows or /usr/bin/git on Linux).

On Windows, if you install Git after VS Code, you may need to sign out and sign back in, or restart your computer, for the PATH update to take effect everywhere.

Once Git is working, explore how to /vscode/how-to-stage-commit-push-and-pull-changes-in-vs-code to start tracking your code.

Rune AI

Rune AI

Key Insights

  • Install Git from git-scm.com before using source control in VS Code.
  • Configure your global name and email with git config --global user.name and git config --global user.email.
  • VS Code detects Git automatically; the Source Control icon in the Activity Bar confirms it.
  • Restart VS Code after installing Git so the editor picks up the new installation.
  • Use per-repository config (git config without --global) to override your identity for a specific project.
RunePowered by Rune AI

Frequently Asked Questions

How do I check if Git is already installed?

Open a terminal and run `git --version`. If Git is installed, you will see the version number. If not, you will see a command-not-found error and need to install Git.

What happens if I do not configure a Git username and email?

Git will refuse to commit changes. VS Code shows a warning in the Source Control view and asks you to configure your identity before you can commit.

Can I use a different name and email for a single repository?

Yes. Open the terminal in that repository and run `git config user.name "Your Name"` and `git config user.email "your.email@example.com"` without the `--global` flag. The per-repository config overrides the global config.

Does VS Code come with its own Git installation?

No. VS Code uses the Git installation on your machine. You must install Git separately before VS Code's source control features work.

Conclusion

Once Git is installed and your name and email are configured, VS Code detects Git automatically. The Source Control icon in the Activity Bar confirms Git is ready, and you can move on to cloning a repository or initializing your first project.