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后,我也遇到了同样的问题!
我使用下面的命令,它为我工作!
git --version
确认你是否已经安装了git,如果没有运行
brew install git
安装最新版本。
安装成功后,运行
brew link git
如果它不能符号链接,因为目标已经存在,你可以运行
brew link --overwrite git
覆盖它。
希望这对你有用!
其他回答
在升级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。
升级到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",
首先检查Git*是否安装在你的系统中,在cmd /命令提示符中输入命令(在Windows中):
where git
如果你得到这样的输出,
λ where git
C:\cmder\vendor\git-for-windows\cmd\git.exe
然后进入设置→首选项→设置,把下面的代码**放在右边。
{
// If git enabled?
"git.enabled": true,
// Path to the Git executable
"git.path": "C:\\cmder\\vendor\\git-for-windows\\cmd\\git.exe"
}
如果您没有安装Git,请从https://git-scm.com/安装Git
**只需添加一个双斜杠(\\),就像上面的代码一样。
如果git在操作系统更新后丢失,在我的大苏尔的情况下,只是字面上:brew install git
运行 它会提示你安装命令行开发工具。安装工具并重新启动VScode。 你会在VScode中再次看到git工作