[git] Visual Studio Code cannot detect installed git

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.

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, 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.

  • On "Search Windows", search for "regedit". Right-click to open as Admin.
  • 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 here6 [enter image description here]6