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 re-install 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?
This question is related to
git
visual-studio-code
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.
Went through this $h!†
again after updating to Catalina, which requires an XCode
update.
And to clarify, while this post is about VS Code
, this issue, is system wide. Your git
install is affected/hosed. You can try to run git
in your terminal/bash/zsh or whatever it is now and it just won't.
Same fix, just update XCode
, start it up and agree to license. That's it.
Old post, but just hit this on MAC/OSX
so hope this helps someone.
VS Code
for some time and have no issues with Git
XCode
(for whatever reason - OS update, etc)XCode
, VS Code
suddenly "can't find Git and asks you to either install or set the Path in settings"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
Happy holidays and happy coding :)
I had this problem after upgrading to macOS Catalina.
The issue is resolved as follows:
whereis git 2. Add the location of git in settings file with your location:
settings.json
"git.path": "/usr/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
VSCode 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.
In Visual Studio Code open 'user settings': ctrl + p
and type >sett
press enter
This will open default settings on left side and User settings on right side.
Just add 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
What worked for me was manually adding the path variable in my system.
I followed the instructions from Method 3 in this post:
https://appuals.com/fix-git-is-not-recognized-as-an-internal-or-external-command/
After an OSX update i had to run xcode-select --install
for the gitlens to work
In my case GIT was installed on my WIndows 10 OS and there was an entry in PATH variable. But VS CODE 1.52.1 still unable to detect it from terminal window but it was available in CMD console.
Problem was solved by switching terminal from PowerShell to CMD or Shell + VsCode restart.
If you have multiple environments. You could include Git Path in the VS Code Workspace Setting. For Windows, depending on your setting, you could hit Ctlr + P, search for "settings". Open setting.json(or 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, e,g
SETX PATH "%PATH%;Path_to_Git_bin;Path_to_Gt_cmd;"
This will make git available on local root but not on 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 dues to Path length(getting "Error: Truncated at X characters." message), you can increase the path length on regedit.
This will increase your path length. If it is already one, then I am not sure how to proceed from there :).
Follow this :
1. File > Preferences > setting
2. In search type -> git path
3. Now scroll down a little > you will see "Git:path" section.
4. Click "Edit in settings.json".
5. Now just paste this path there "C:\\Program Files\\Git\\mingw64\\libexec\\git-core\\git.exe"
Restart VSCode and open new terminal in VSCode and try "git version"
In case still problem exists :
1. Inside terminal click on terminal options (1:Poweshell)
2. Select default shell
3. Select bash
open new terminal and change terminal option to 2:Bash Again try "git version" - this should work :)
Hope that helped, and last but not least, it's 'git' not 'Git'/'gat'. :)
i have recently start visual studio code and have this issue and just write the exact path of executable git solve the issue .... here is the code ...
"git.path": "C:\Program Files\Git\bin\git.exe",
I had this problem after upgrading to macOS Catalina.
The issue is resolved as follows:
1. Find 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
I faced this problem on MacOS High Sierra 10.13.5
after upgrading Xcode
.
When I run git
command, I received below message:
Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.
After running sudo xcodebuild -license
command, 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 Enter
key to open license agreements and typing space
key to review details of it, until 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 git
command, we can check that VSCode detected git again.
I found that i had git: false in settings.json. Changed it to true and works now.
Now you can configure Visual Studio Code (version 0.10.2, check for older versions) to use existing git installation.
Just add the path to the git executable in your Visual Studio Code settings (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
}
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
First install Git onto your desktop, then Add the encircled extension in vscode, as seen in the picture.
That helped me fix the same issue you have.
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.
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
First check if Git* 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"
}
** Just add double slash (\\
) just like the above code.
here's what worked for me, instead of using the visual code terminal to run your git commands, run the git commands from a cmd terminal at the path of your application
For Linux based OS. I had such an issue due to a corrupted path but was able to temporarily fix the issue and my git was immediately restored.
In case you're facing such path issue type the command below
export PATH="/usr/bin:/bin:$PATH"
Three years later, I ran into the same issue. Setting the path in user settings & PATH environment variable didn't help. I updated VSCode and that solved it.
Source: Stackoverflow.com