VS Code: Git not found. Install it or configure it using the 'git.path' setting

avatar
Borislav Hadzhiev

Last updated: Apr 6, 2024
5 min

banner

# VS Code: Git not found. Install it or configure it using the 'git.path' setting

The VS Code error "Git not found. Install it or configure it using the 'git.path' setting" occurs when VS Code can't find where git is installed on your machine.

You can resolve the error by making sure Git is installed and configuring the git.path setting in VS Code.

You might get any of the following variations of the error.j

shell
It looks like git is not installed on your system Git not found. Install it or configure it using the 'git.path' setting GitLens was unable to find Git. Please make sure Git is installed. Also ensure that Git is either in the PATH, or that 'gitlens.advanced.git' is pointed to its installed location There are no active source control providers. no source control providers registered

Make sure Git is installed on your machine and is added to your PATH environment variable.

You can start your terminal and issue the git --version command.

shell
git --version

verify if git is installed

If you get a version number back, then Git is installed on your machine.

Otherwise, follow the official installation instructions for your operating system.

If you get the "xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)" error on macOS, click on the following subheading:

# Configure Git correctly in VS Code

If you have Git installed, try to set the git.path property in VS Code.

On Windows, issue the following command to find where the git.exe file is located.

cmd
# Windows where git

find where git is installed on windows

Make note of the directory, it might be something similar to:

  • C:\Program Files\Git\bin\git.exe
  • or C:\Program Files\Git\cmd\git.exe

On macOS or Linux, issue the following command to find where git is located.

shell
which git

find git on macos linux

The path might be something similar to:

  • /usr/local/bin/git
  • or /usr/bin/git

Make note of the path.

  1. Press Ctrl + Shift + P (or Command + Shift + P on macOS).
Note: you can also press F1 to open the Command Palette.
  1. Type user settings json.

  2. Click on Preferences: Open User Settings (JSON)

preferences open user settings

  1. Add the following properties to your settings object.
settings.json
{ // Enable Git in VS Code "git.enabled": true, // Point to the Git executable "git.path": "C:\\path\\to\\your\\git.exe" }

Make sure to specify the correct path to the git executable.

On Windows, you have to escape each backslash with another backslash as shown in the following example.

set path to git in settings json

On macOS and Linux, you don't have to escape the path as it only contains forward slashes, e.g. /usr/local/bin/git.

NOTE: the git.path property can also be set to an array of paths to your git executables if you have multiple.

settings.json
{ // Enable Git in VS Code "git.enabled": true, // Point to the Git executable "git.path": [ "C:\\path\\to\\your\\git.exe", "C:\\path\\to\\another\\git.exe", "C:\\path\\to\\third\\git.exe" ] }

If set to an array, the git extension goes to all of the values in the array until it finds a usable git executable.

After setting the git.enabled and git.path properties:

  1. Save your settings.json file.
  2. Restart VS Code. This step is very important.
  3. Check if the error is resolved.

If you couldn't find the settings.json file:

  1. Press Ctrl + Shift + P (or Command + Shift + P on macOS).
Note: you can also press F1 to open the Command Palette.
  1. Type user settings and select Preferences: Open User Settings.

open user settings

You can also open the settings screen by pressing Ctrl + , on Windows and Linux or Cmd + , on macOS.

  1. Click on the Open Settings (JSON) icon at the top right corner.

click open settings json icon

If the error persists and you use PowerShell on Windows, try switching to Git Bash or CMD instead.

PowerShell often causes issues when used with VS Code.

After you switch your shell to CMD or Git Bash, restart VS Code.

# Installing git correctly on macOS

If you are on macOS and the error persists, try to run the following command to install the Apple version of git.

shell
xcode-select --install

Try to issue the which git command after, and you should be able to see a valid path.

shell
which git

When you issue the git --version command, you might get prompted to agree to the license.

shell
git --version

Make sure to agree to the license as that often causes the error.

If the error persists, run the following command to agree to the license.

shell
sudo xcodebuild -license

Agreeing to the Xcode/iOS license requires admin privileges.

Hit the Enter key to view the license agreement.

You can also run the command with the accept option.

shell
sudo xcodebuild -license accept

Once you agree to the license, restart VS Code and check if the error is resolved.

You can also install git using brew.

shell
brew install git

Alternatively, you can follow the official installation instructions.

# There are no active source control providers

If you get the error message There are no active source control providers:

  1. Click on Extensions in the left sidebar.
  • You can also open the Extensions menu by pressing:
    • Ctrl + Shift + X on Windows or Linux.
    • Command + Shift + X on macOS.
  1. Type @builtin git.

make sure git extension installed and enabled

  1. Make sure the extension is installed and enabled.

The built-in Git and Git Base extensions from vscode must be installed and enabled.

Another thing you should check is that the Git: Enabled checkbox is checked in your settings.

  1. Press Ctrl + Shift + P (or Command + Shift + P on macOS).
Note: you can also press F1 to open the Command Palette.
  1. Type user settings and select Preferences: Open User Settings.

open user settings

You can also open the settings screen by pressing Ctrl + , on Windows and Linux or Cmd + , on macOS.

  1. Scroll down to the Git: Enabled checkbox and make sure it is checked.

check git enabled checkbox

If you don't have a git repository in your project, initialize one by running the git init command.

  1. Press:
  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.
Note: you can also press F1 to open the Command Palette.
  1. Type toggle terminal and select View: Toggle Terminal.

vscode open terminal

  1. Run the git init command.
shell
git init

# Try restarting your computer

If the error persists, try to restart your computer as you might have stale configuration.

The VS Code git configuration often glitches and a reboot often helps.

I've also written an article on how to use VS Code as your default Git editor, difftool and mergetool.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.