Visual Studio Code cannot detect installed git

后端 未结 21 2182
走了就别回头了
走了就别回头了 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

    After an OSX update i had to run xcode-select --install for the gitlens to work

    0 讨论(0)
  • 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

    0 讨论(0)
  • 2020-11-30 22:38

    Version control

    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.

    0 讨论(0)
  • 2020-11-30 22:39

    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.

    0 讨论(0)
  • 2020-11-30 22:45

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

    0 讨论(0)
  • 2020-11-30 22:48
    1. Make sure git is enabled (File --> Preferences --> Git Enabled) as other have mentioned.
    2. Make sure Gits installed and in the PATH (with the correct location, by default: C:\Program Files\Git\cmd) - PATH on system variables btw
    3. Change default terminal, Powershell can be a bit funny, I recommend Git BASH but cmd is fine, this can be done by selecting the terminal dropdown and selecting 'set default shell' then creating a new terminal with the + button.
    4. Restarting VS Code, sometimes Reboot if that fails.

    Hope that helped, and last but not least, it's 'git' not 'Git'/'gat'. :)

    0 讨论(0)
提交回复
热议问题