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?
当前回答
升级到MacOS Ventura < 13.0
截至2022年11月
升级到MacOS Ventura似乎不会对编码环境产生太大影响。
升级到macOS Ventura后,你的终端和VScode会出现一些错误。如:
It look 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
有些错误取决于您的ZSH设置或其他自定义。
这些常见问题可以通过简单地重新安装xcode命令行工具和更新Homebrew来解决-因为您的终端可能会受到影响,从apple可执行文件重新安装https://developer.apple.com/download/all/ Developer.apple.com你需要用你的apple id登录。
安装完成后,更新Homebrew
brew upgrade
Mac M1 - M2机器可能有一些本地和ARM应用程序,所以运行:
arch -arm64 brew upgrade
关闭所有终端和Vscode重新启动!
重新打开Vscode,错误应该消失了。
如果Vscode还在寻找Git路径,你需要手动添加它。
找到git的位置并从终端复制:
which git
并在你的Visual Studio Code JSON设置文件(file -> Preferences -> settings)中添加到git可执行文件的路径,查找并更新行-应该看起来类似:
"git.path": "/usr/local/bin/git",
其他回答
我编辑路径到系统环境,并添加“C:\Program Files\Git\bin”,然后重新启动Vscode。这对我很有效。我不明白为什么我正常使用它,然后我有这个问题。也许在安装某个东西的过程中会引起这个问题。
三年后,我遇到了同样的问题。在用户设置& path环境变量中设置路径没有帮助。我更新了Visual Studio Code,这就解决了问题。
通过安装Git Lens Visual Code扩展,我在MacOS上用m1 pro处理器解决了同样的问题。启用扩展名后显示更改的文件。然后我重新加载VSCode,没有任何变化,但一旦我运行
git status
在终端中,显示所有的文件,并跟踪所有的更改。
我只需要从这个链接https://git-scm.com/download/win为windows安装git就可以了
不需要设置环境变量或路径。
背景: 我已经安装了VS Code,和github桌面,我克隆的回购使用github桌面。
当我打开repo时,使用VS Code,我看到了这个错误。
我通过为windows安装git来解决这个问题。
VSCode 1.50(2020年9月)在问题85734中添加了一个有趣的替代方案:
Support multiple values for the git.path setting I 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.
这是通过PR 85954和提交c334da1解决的。
使用VSCode 1.60+
“git。启用”:真正的 git.path