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?
当前回答
在升级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。
其他回答
更新2020 (Mac)
我经过了这个$h!†再次更新到macOS v10.15 (Catalina),这需要Xcode更新。
要澄清的是,虽然这篇文章是关于Visual Studio代码的,但这个问题是系统范围内的。Git安装受到影响。你可以试着在你的终端、Bash、Z shell (zsh)或其他工具中运行git。现在是,以后也不会了。
这是同样的方法。更新Xcode即可。启动它并同意许可。就是这样。
我在Mac/OS X上打了这个。
症状:
你已经使用Visual Studio Code一段时间了,Git没有任何问题 你安装Xcode(不管什么原因-操作系统更新等) 在安装Xcode后,Visual Studio Code突然“找不到Git,并要求你在设置中安装或设置路径”
快速修复:
运行Xcode(安装后第一次)并同意许可。就是这样。
我是如何偶然发现这个“解决方案”的:
在经历了许多关于检查git的技巧后,例如,哪个git和git——版本,后者实际上提供了以下终端消息的线索:
同意Xcode/iOS许可证需要管理员权限,请运行" sudo xcodebuild -license ",然后重试此命令。
至于为什么Xcode会把它的手放在git上,WAT。
如果你有多个环境。你可以在Visual Studio代码工作区设置中包含Git路径。对于Windows,根据你的设置,你可以按Ctrl + P,搜索“settings”。打开设置。json(或菜单文件→首选项→设置)。导航到工作区设置。找到“Path”并在Git bin和cmd文件夹中添加路径。
环境可以有自己的路径。当我在cmd上回显我的PC %PATH%时,我发现了这一点。Git bin和cmd路径可用,但当我在我的项目中工作时,回显% path %没有Git和cmd文件夹。如上所示,添加它们就解决了这个问题。
额外的注释:
在cmd上,你可以回显“%PATH%”,看看git bin和cmd文件夹是否包括在内。如果没有,您可以使用SETX PATH连接,例如,
SETX PATH "%PATH%;Path_to_Git_bin;Path_to_Gt_cmd;"
这将使git在本地根目录下可用,但在一些有自己路径的环境中不可用(SETX /M PATH "%PATH%;Path_to_Git_bin;Path_to_Gt_cmd;"会有)。
如果你有一个很长的路径,由于路径长度而被切断(得到“错误:截断X字符”消息),你可以在RegEdit中增加路径长度。
在“搜索窗口”中搜索“regedit”。右键单击以Administrator打开。 打开“Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem” 右键单击并修改。将值数据从0更改为1
这将增加路径长度。如果它已经是一个,那么我不确定如何从那里进行:)。
[9
Make sure git is enabled (File --> Preferences --> Git Enabled) as other have mentioned. Make sure Gits installed and in the PATH (with the correct location, by default: C:\Program Files\Git\cmd) - PATH on system variables btw 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. Restarting VS Code, sometimes Reboot if that fails.
希望这对你有所帮助,最后但并非最不重要的是,它是'git'而不是'git' /'gat'。:)
我最近开始使用Visual Studio Code。我有这个问题,只是写Git可执行文件的确切路径解决 这个问题。代码如下:
“git。C:\Program Files\Git\bin\ Git .exe
运行 它会提示你安装命令行开发工具。安装工具并重新启动VScode。 你会在VScode中再次看到git工作