293

Visual Studio Code reports "It look like git is not installed on your system." when I try to switch to the git view. I know I have git installed and used by other Git clients. I guess if I reinstall Git following Visual Studio Code's instruction ("install it with Chocolatey or download it from git-scm.com"), it probably can fix the problem, but I don't want to mess up the existing Git clients on my system. Is there a reliable way to configure Visual Studio Code so it can find existing git installation?

15
  • Did you do an actual Git for Windows installation, or did you use Portable Git? Is git in your PATH? Commented Apr 30, 2015 at 16:05
  • 1
    @EdwardThomson I don't think I actually installed Git for Windows and that is exactly my problem. I didn't have git in PATH. I have various git's: GiHub client, SourceTree, Eclipse plugin, even cygwin. I added cygwin path to PATH just for the reason of curiosity and VS Code found it! Thanks for hint! Installing Git for Windows probably is still the right thing to do. (Now I need to figure out how to set the workspace properly so VS Code will not complain "This workspace isn't yet under git source control" but that will be a different question.) Commented Apr 30, 2015 at 16:49
  • Cool, I'll add this as an answer. Commented Apr 30, 2015 at 17:02
  • 6
    I have this problem, ONLY when running VS Code "as administrator", the git.path is not overridden in my normal user (non-admin) VS Code, but seems to find git just fine over there. Overriding git.path while in administrator mode (and then restarting VS Code) did not seem to help. My error: Git not found. Install it or configure it using the git.path setting. Commented Oct 5, 2018 at 14:35
  • 1
    UPDATE: I finally figured out that there's a system PATH variable, and then USER-specific PATH variables, and the Git was only in 1 of my user-specific PATHs Commented Oct 5, 2018 at 14:45

40 Answers 40

246

Now you can configure Visual Studio Code (version 0.10.2, check for older versions) to use an existing Git installation.

Just add the path to the Git executable in your Visual Studio Code settings (menu FilePreferencesSettings) like this:

{
    // Is Git enabled
    "git.enabled": true,

    // Path to the Git executable
    "git.path": "C:\\path\\to\\git.exe"

    // Other settings
}
Sign up to request clarification or add additional context in comments.

12 Comments

Make sure you install a version of git that understands Windows paths though. The one from MSYS2's pacman repo doesn't work for example.
Note tha you must restart vscode so the changes make effect.
newbs like me, your settings are here: file -> preferences -> settings
it works for me after adding this path "git.path":"C:\\Program Files\\GitWP\\bin\\git.exe"
Use CTRL + Shift + P and Open Settings (JSON) if only the UI option appears. stackoverflow.com/questions/65908987/…
|
180

Update 2020 (Mac)

I went through this $h!† again after updating to macOS v10.15 (Catalina), which requires an Xcode update.

And to clarify, while this post is about Visual Studio Code, this issue, is system wide. Your Git install is affected/hosed. You can try to run git in your terminal, Bash, Z shell (zsh), or whatever. It is now and it just won't.

There are two possible fixes:

  • Just update Xcode. Start it up and agree to the license. That's it.
  • Or run sudo xcodebuild -license in a Terminal

I hit this on Mac/OS X.

Symptoms:

  • You've been using Visual Studio Code for some time and have don’t have any issues with Git
  • You install Xcode (for whatever reason - OS update, etc.)
  • After installing Xcode, Visual Studio Code suddenly "can't find Git and asks you to either install or set the Path in settings"

Quick fix:

Run Xcode (for the first time, after installing) and agree to license. That's it.

How I stumbled upon this "fix":

After going through numerous tips about checking git, e.g., which git and git --version, the latter actually offered clues with this Terminal message:

Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.

As to why Xcode would even wrap it's hands on git, WAT.

14 Comments

Here again, after updating to Catalina... :|
This solution did not work for me, but running the following did: xcode-select --install [source]
With BigSur 11.2 running xcode-select --install does not work. With every MacOS update I've found I needed to reinstall the Command Line Tools regardless even if Xcode was up to date. Download from Apple – developer.apple.com/download/more/?=xcode
Reinstalling command line tools did the trick for me too.
I stumbled on this too when I upgraded to Monterey. I had to do the xcode-select --install and then do a brew upgrade.
|
101

Visual Studio Code simply looks in your PATH for git. Many UI clients ship with a "Portable Git" for simplicity, and do not add git to the path.

If you add your existing git client to your PATH (so that it can find git.exe), Visual Studio Code should enable Git source control management.

14 Comments

If you update your git-path in your user settings within visual studio code from null to "F:\\Program Files\\Git\\mingw64\\libexec\\git-core\\git.exe" (or something similar) you should simply have to restart VSCode and git will open successfully. My only addition is that if you do not use the git.exe within the directory mingw64\libexec\git-core\git.exe VSCode will open with various errors and bash terminals.
@Eric, Adding { "git-path":"d:\\Program Files\\Git\\bin\\gite.exe" } didn't work, vscode still search in c:\...
@Eric, but OK, git.path did the job: "git.path":"d:\\Program Files\\Git\\bin\\git.exe" ;-)
This worked for me, although I had to reboot my machine (windows 10) which I didn't think I need to. Anyway, whatever works.
git.path does not exist - where would this need to be added exactly? (OS: Windows 10 64-bit)
|
74

I had this problem after upgrading to macOS v10.15 (Catalina).

The issue is resolved as follows:

1.

Find the Git location from the terminal:

which git

2.

Add the location of Git in settings file with your location:

settings.json

"git.path": "/usr/local/bin/git",

Depending on your platform, the user settings file (settings.json) is located here:

Windows %APPDATA%\Code\User\settings.json

macOS $HOME/Library/Application Support/Code/User/settings.json

Linux $HOME/.config/Code/User/settings.json

3 Comments

The same error happened when I updated macOS to Ventura 13. And this solution fixed my problem.
Hi @Zac I also using same laptop but I could not fix this issue, I did not understand the last step where do I want add the line - $HOME/Library/Application Support/Code/User/settings.json guid me please
@BharathMb, you don't need to add this file manually. In vscode, open user setting (JSON). And it shows you the file.
52

This can happen after upgrading macOS. Try running Git from a terminal and see if the error message begins with:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) ...

If so, the fix is to run:

xcode-select --install

from the terminal. See this answer for more details.

1 Comment

Bless you sweet Justin
31

In Visual Studio Code, open 'User Settings': Ctrl + P and type >sett. Press Enter.

This will open the default settings on the left side and User Settings on the right side.

Just add the path to git.exe in user settings:

"git.path": "C:\\Users\\[WINDOWS_USER]\\AppData\\Local\\Programs\\Git\\bin\\git.exe"

Replace [WINDOWS_USER] with your user name.

Restart Visual Studio Code.

3 Comments

Mine went like this (version: )
@Bartosh Is it better to add the setting to the user.settings file rather than updating the default.settings?
">user" is more specific than ">sett" (Visual Studio Code 1.74.3).
17

First check if Git* is installed or not in your system by typing the command in cmd /command prompt (in Windows):

where git

If you get an output like this,

λ where git
C:\cmder\vendor\git-for-windows\cmd\git.exe

Then Go to SettingsPreferencesSettings and put the bellow code** right part.

 {
    // If git enabled?
    "git.enabled": true,

    // Path to the Git executable
    "git.path": "C:\\cmder\\vendor\\git-for-windows\\cmd\\git.exe"
}

** Just add a double slash (\\), just like the above code.

1 Comment

File > Preferences > Settings > User Settings > Extensions > Git > Path > Edit in settings.json (if the displayed path isn't correct)
12

Upgrade to macOS v13 (Ventura) < 13.0

As of November 2022

Upgrading to macOS v13 (Ventura) does not seem to affect your coding environments too much.

After upgrading to macOS v13, your Terminal and Visual Studio Code will give off a few errors. Such as:

It looks like Git is not installed on your system ..

or

can't find Git and asks you to either install or set the Path in settings

Some errors depend on your Z shell (zsh) setup or other customizations.

These common problems can be resolved by simply by reinstalling the Xcode command-line tools and updating Homebrew - since your terminal might be affected, reinstall from Apple's executable https://developer.apple.com/download/all/ developer.apple.com. You will need to log in with your Apple ID.

Once installed, update Homebrew:

brew upgrade

Mac M1 - M2 machines likely have some native and ARM applications, so run:

arch -arm64 brew upgrade

Close all terminals and Visual Studio Code to restart!

Reopen Visual Studio Code, and the errors should be gone.

If Visual Studio Code is still looking for the Git path, you will need to add it manually.

Find the Git location and copy from the terminal:

which git

And add the path to the Git executable in your Visual Studio Code JSON settings file (menu FilePreferencesSettings) find and update the line. It should look similar to:

"git.path": "/usr/local/bin/git",

2 Comments

Downloading xcode command line tools & brew upgrade fixed my issues. Very appreciated, can't thank you enough for this post!
Doing this in 2023, brew upgrade was the important step that I initally missed but after the long update and restarting it worked. So in your mac also try this as well apart from setting your git path. THnx
12

macOS - Visual Studio Code.

Step 1: Go to Visual Studio Code, menu FilePreferencesSettings (or Ctrl + ,).

Step 2: Type 'Path' in the search bar. You will get a result list that contains Git.

Step 3: Click on Git. After that, click on Edit in settings JSON file.

Step 4: In your Mac Terminal, type which git. You will get the Git path

Step 5: Just copy that path and add again the path key in the JSON file.

1 Comment

There are too many hits for "Path" in Ctrl + ,. Can you make it more specific to get the number of hits to a more manageable level? (But *** *** *** *** *** *** *** *** *** *** *** *** without *** *** *** *** *** *** *** *** *** *** *** *** "Edit:", "Update:", or similar - the answer should appear as if it was written today).
8

After an OS X update, I had to run xcode-select --install for GitLens to work.

1 Comment

This worked for me on OS X 10.14 (Mojave). I had already installed xcode from the app store, but never installed the command line tools.
8

I ran into the same problem after!

How did I fix it?

Step 1: Go to the Settings in Visual Studio Code.

Step 2: Open settings.json.

Step 3: You need to find something like "git.path" in settings.json

Step 4: just add the directory path where Git is installed in your system.

Example: "git.path": "D:/Git/bin/git.exe"

Step 5: Restart your Visual Studio Code.

1 Comment

Re "I ran into the same problem after": After what?
6

Run xcode-select --install. It'll prompt you to install command line developer tools. Install the tools and restart your Visual Studio Code.

You'll see Git working once again in Visual Studio Code.

Comments

5

I ran into this problem after upgrading my macOS to macOS v12 (Monterey).

It turned out that Xcode has been removed in the new update from my mac. I Just tried the following suggested solution:

Git is not working after macOS update ("xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools")

Comments

4

Visual Studio Code 1.50 (Sept 2020) adds an interesting alternative with issue 85734:

Support multiple values for the git.path setting

I use VSCode in three different places; my home computer, my work computer, and as a portable version I carry on a drive when I need to use a machine that doesn't have it.

I use an extension to keep my settings synced up between editors, and the only issue I've encountered so far is that the git path doesn't match between any of them.

  • On my home machine I have it installed to C of course,
  • work likes to be funny and install it on A,
  • and for the one on my drive I have a relative path set so that no matter what letter my drive gets, that VSCode can always find git.

I already attempted to use an array myself just to see if it'd work:

"git.path": ["C:\\Program Files\\Git\\bin\\git.exe", "A:\\Git\\bin\\git.exe", "..\\..\\Git\\bin\\git.exe"],

But VSCode reads it as one entire value.

What I'd like is for it to recognize it as an array and then try each path in order until it finds Git or runs out of paths.

This is addressed with PR 85954 and commit c334da1.


With Visual Studio Code 1.60+

  • "git.enabled": true
  • git.path

Comments

3

I faced this problem on macOS v10.13.5 (High Sierra) after upgrading Xcode.

When I run the git command, I received the below message:

Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.

After running the sudo xcodebuild -license command, the below message appears:

You have not agreed to the Xcode license agreements. You must agree to both license agreements below in order to use Xcode.

Hit the Enter key to view the license agreements at '/Applications/Xcode.app/Contents/Resources/English.lproj/License.rtf'

Typing the Enter key to open the license agreements and typing the space key to review details of it, until the below message appears:

By typing 'agree' you are agreeing to the terms of the software license agreements. Type 'print' to print them or anything else to cancel, [agree, print, cancel]

The final step is simply typing agree to sign with the license agreement.


After typing the git command, we can check that Visual Studio Code detected Git again.

Comments

3

For Mac

First, type

git

in the terminal and see what error you are getting.

Then:

If the error is related to a command line tool!

Run:

xcode-select --install

And

Just go ahead and go through this answer. For Mac especially. It worked very easily for me:

Why am I getting an “invalid active developer path” when attempting to use Git after upgrading to macOS Ventura?

Comments

2

I have recently started with Visual Studio Code. I have this issue and just writing the exact path of the Git executable solves the issue. Here is the code:

"git.path": "C:\Program Files\Git\bin\git.exe",

1 Comment

For me worked only with double backslashes: "git.path": "C:\\Data\\App\\Git\\bin\\git.exe"
2

If you have multiple environments. You could include Git Path in the Visual Studio Code Workspace Setting. For Windows, depending on your setting, you could hit Ctrl + P, search for "settings". Open settings.json (or menu FilePreferencesSettings). Navigate to Workspace Settings. Find "Path" and add paths to Git bin and cmd folders.

Enter image description here

Enter image description here

Enter image description here

Enter image description here

Environments can have their own paths. I discovered this when I echoed my PC %PATH% on cmd. Git bin and cmd path where available, but when I was working on my project, echoed %PATH% did not have git and cmd folder. Adding them, as shown above, solved the issue.

Extra Notes:

On cmd, you can echo "%PATH%" and see if git bin and cmd folders are included. If not, you could concatenate using SETX PATH on, for example,

SETX PATH "%PATH%;Path_to_Git_bin;Path_to_Gt_cmd;"

This will make git available on local, root but not in some environments which comes with their own paths (SETX /M PATH "%PATH%;Path_to_Git_bin;Path_to_Gt_cmd;" would have though).

In case you have a long Path that is chopped off due to Path length (getting "Error: Truncated at X characters." message), you can increase the path length in RegEdit.

  • In "Search Windows", search for "regedit". Right-click to open as Administrator.
  • Go to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
  • Right-click and modify. Change value data from 0 to 1

This will increase your path length. If it is already one, then I am not sure how to proceed from there :).

[Enter image description here9

Enter image description here

Comments

1

Three years later, I ran into the same issue. Setting the path in user settings & PATH environment variable didn't help. I updated Visual Studio Code and that solved it.

Comments

1

Version control

First install Git onto your desktop, and then add the encircled extension in Visual Studio Code, as seen in the picture.

That helped me fix the same issue you have.

Comments

1

Open

C:\Users\nassim\AppData\Roaming\Code\User\settings.json

Comment any Git line there:

// ...
// "git-graph.integratedTerminalShell": "E:\\Apps\\Git\\bin\\bash.exe",
// "git.path": ""
//...

And add git.exe to the OS path.

Note for me: Fixing this Git error also fixed the npm error too. Since they are both defined in the path, if one fail, the remaining will fail as well.

Comments

1

In my case, Git was installed on my Windows 10 OS and there was an entry in PATH variable. But Visual Studio Code 1.52.1 still is unable to detect it from a terminal window, but it was available in a CMD console.

The problem was solved by switching the terminal from PowerShell to CMD or shell, and a Visual Studio Code restart.

Comments

1
  1. Make sure Git is enabled (menu FilePreferencesGit Enabled) as other have mentioned.
  2. Make sure Git is installed and in the PATH (with the correct location, by default: C:\Program Files\Git\cmd) - PATH in System Variables, BTW
  3. Change the default terminal. PowerShell can be a bit funny, and I recommend Git Bash, but cmd is fine. This can be done by selecting the terminal dropdown and selecting 'set default shell' and then creating a new terminal with the + button.
  4. Restart Visual Studio Code, and sometimes reboot if that fails.

1 Comment

You are the first person that mentioned "reboot" -- this is important because windows system PATH changes do not take effect until you restart the machine, not even logging out appeared to do it for me though I verified in advanced settings on the machine, in the environment variables area that it was definitely there.
1

If Git is missing after the OS update, in my case macOS v11 (Big Sur), just literally:

brew install git

1 Comment

Where? In what environment? In a separate terminal window? Inside Visual Studio Code somewhere? Or somewhere else?
1

I solved the same problem on macOS with an M1 Pro processor by installing the GitLens Visual Code extension. The changed files were displayed after enabling the extension. Then I turned to reloading Visual Studio Code and there were no changes, but once I ran

git status

in the terminal, it showed all the files, and all changes were tracked.

Comments

1

The only way I could get to work in my Windows 8.1 is the following:

Add to system environment variables (not user variables):

C:\Users\USERNAME\AppData\Local\GitHub\PortableGit_YOURVERSION\bin;C:\Users\USERNAME\AppData\Local\GitHub\PortableGit_YOURVERSION\libexec\git-core;C:\Users\USERNAME\AppData\Local\GitHub\PortableGit_YOURVERSION\cmd\

This fixed the "it looks like Git is not installed on your system" error on my Visual Studio Code.

Comments

1

I faced this issue after updating macOS!

I installed Git again using Homebrew, and it worked!

brew install git

Comments

0

I edited Path into System Environment and add "C:\Program Files\Git\bin" then restart Vscode. It's worked for me. I don't understand why I am using it normally then I have this problem. Maybe during the installation of something it causes that problem.

Comments

0

I found that I had git: false in settings.json and changed it to true. It works now.

Comments

0

Here's what worked for me. Instead of using the Visual Studio Code terminal to run your Git commands, run the Git commands from a cmd terminal at the path of your application.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.