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?
当前回答
在我的例子中,GIT安装在我的WIndows 10操作系统上,在PATH变量中有一个条目。但是VS CODE 1.52.1仍然无法从终端窗口检测到它,但在CMD控制台中可用。
通过将终端从PowerShell切换到CMD或Shell + VsCode重启解决了这个问题。
其他回答
Visual Studio Code只是在PATH中查找git。为了简单起见,许多UI客户端附带了“可移植Git”,并且没有将Git添加到路径中。
如果您将现有的git客户端添加到您的PATH(以便它可以找到git.exe), Visual Studio Code应该启用git源代码控制管理。
我在Windows 8.1系统下工作的唯一方法是: 添加到系统环境变量(不是用户变量):
c:\Users\USERNAME\AppData\Local\GitHub\ PortableGit_YOURVERSION \ bin \; c: \ \用户名\ AppData \用户本地\ GitHub \ PortableGit_YOURVERSION \ libexec \ git-core \;当地用户c: \ \用户名\ AppData \ \ GitHub \ PortableGit_YOURVERSION \ cmd \
这修复了我的Visual Studio代码上的“看起来git没有安装在您的系统上”错误。
三年后,我遇到了同样的问题。在用户设置& path环境变量中设置路径没有帮助。我更新了Visual Studio Code,这就解决了问题。
升级到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",
在更新macOS后遇到了这个问题!
再次使用自制软件安装git,它工作了!
brew install git