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?
40 Answers
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 File → Preferences → Settings) like this:
{
// Is Git enabled
"git.enabled": true,
// Path to the Git executable
"git.path": "C:\\path\\to\\git.exe"
// Other settings
}
12 Comments
CTRL + Shift + P
and Open Settings (JSON)
if only the UI option appears. stackoverflow.com/questions/65908987/…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
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/?=xcodexcode-select --install
and then do a brew upgrade
.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
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.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:
"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
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
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
>user
" is more specific than ">sett
" (Visual Studio Code 1.74.3).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 Settings → Preferences → Settings 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"
}
- If you don't have Git installed, install Git from https://git-scm.com/
** Just add a double slash (\\
), just like the above code.
1 Comment
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 File → Preferences → Settings) find and update the line. It should look similar to:
"git.path": "/usr/local/bin/git",
2 Comments
macOS - Visual Studio Code.
Step 1: Go to Visual Studio Code, menu File → Preferences → Settings (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
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).After an OS X update, I had to run xcode-select --install
for GitLens to work.
1 Comment
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
Visual Studio Code 1.50 (Sept 2020) adds an interesting alternative with issue 85734:
Support multiple values for the
git.path
settingI 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.
"git.enabled": true
git.path
Comments
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
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:
Comments
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
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 File → Preferences → Settings). Navigate to Workspace Settings. Find "Path" and add paths to Git bin and cmd folders.
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 :).
[9
Comments
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
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
- Make sure Git is enabled (menu File → Preferences → Git Enabled) as other have mentioned.
- 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
- 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.
- Restart Visual Studio Code, and sometimes reboot if that fails.
1 Comment
If Git is missing after the OS update, in my case macOS v11 (Big Sur), just literally:
brew install git
1 Comment
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
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
I faced this issue after updating macOS!
I installed Git again using Homebrew, and it worked!
brew install git
Comments
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.
git
in yourPATH
?git.path
is not overridden in my normal user (non-admin) VS Code, but seems to find git just fine over there. Overridinggit.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.