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?
当前回答
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(版本0.10.2,检查旧版本)以使用现有的Git安装。
只需在Visual Studio Code设置(菜单File→Preferences→settings)中添加Git可执行文件的路径,如下所示:
{
// Is Git enabled
"git.enabled": true,
// Path to the Git executable
"git.path": "C:\\path\\to\\git.exe"
// Other settings
}
在我的例子中,GIT安装在我的WIndows 10操作系统上,在PATH变量中有一个条目。但是VS CODE 1.52.1仍然无法从终端窗口检测到它,但在CMD控制台中可用。
通过将终端从PowerShell切换到CMD或Shell + VsCode重启解决了这个问题。
更新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。
首先在桌面上安装Git,然后在Visual Studio Code中添加包围的扩展,如图所示。
帮我解决了和你一样的问题。
在Visual Studio Code中,打开“用户设置”:Ctrl + P并输入>set。按回车。
这将在左侧打开默认设置,在右侧打开用户设置。
只需要在用户设置中添加git.exe的路径:
"git.path": "C:\\Users\\[WINDOWS_USER]\\AppData\\Local\\Programs\\Git\\bin\\git.exe"
用你的用户名替换[WINDOWS_USER]。
重新启动Visual Studio代码。