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?


当前回答

对于MAC

首先,类型

git

在终端中,看看你得到了什么错误。

然后:

如果错误与命令行工具有关!

Run:

xcode-select --install

And

我们来看看这个答案,尤其是Mac。对我来说很容易。

https://apple.stackexchange.com/a/254381

其他回答

以下是对我有效的方法。不要使用Visual Studio Code终端来运行Git命令,而是从应用程序路径下的cmd终端运行Git命令。

运行 它会提示你安装命令行开发工具。安装工具并重新启动VScode。 你会在VScode中再次看到git工作

在我的例子中,GIT安装在我的WIndows 10操作系统上,在PATH变量中有一个条目。但是VS CODE 1.52.1仍然无法从终端窗口检测到它,但在CMD控制台中可用。

通过将终端从PowerShell切换到CMD或Shell + VsCode重启解决了这个问题。

在升级Xcode后,我在macOS v10.13.5 (High Sierra)上遇到了这个问题。

当我运行git命令时,我收到了下面的消息:

同意Xcode/iOS许可证需要管理员权限,请运行" sudo xcodebuild -license ",然后重试此命令。

运行sudo xcodebuild -license命令后,出现如下消息:

您没有同意Xcode许可协议。你必须同意以下两项许可协议才能使用Xcode。 按Enter键查看“/Applications/Xcode.app/Contents/Resources/English.lproj/ license .rtf”中的许可协议

输入Enter键打开许可协议,并输入空格键查看它的详细信息,直到出现以下消息:

输入“同意”即表示您同意软件许可协议的条款。输入'print'打印它们或者其他任何可以取消的东西,[同意,打印,取消]

最后一步是输入agree以签署许可协议。


输入git命令后,我们可以检查Visual Studio Code是否再次检测到git。

Visual Studio Code只是在PATH中查找git。为了简单起见,许多UI客户端附带了“可移植Git”,并且没有将Git添加到路径中。

如果您将现有的git客户端添加到您的PATH(以便它可以找到git.exe), Visual Studio Code应该启用git源代码控制管理。