Visual Studio Code cannot detect installed git

后端 未结 21 2232
走了就别回头了
走了就别回头了 2020-11-30 21:54

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 clie

21条回答
  •  温柔的废话
    2020-11-30 22:36

    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.

    • 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

提交回复
热议问题