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之后。试着在终端上运行Git,看看错误信息是否以:
xrun: error: invalid active developer path (/Library/ developer /CommandLineTools)…
如果是这样,修复是运行:
xcode-select——安装
在终点站。更多细节请看这个答案。
其他回答
我只需要从这个链接https://git-scm.com/download/win为windows安装git就可以了
不需要设置环境变量或路径。
背景: 我已经安装了VS Code,和github桌面,我克隆的回购使用github桌面。
当我打开repo时,使用VS Code,我看到了这个错误。
我通过为windows安装git来解决这个问题。
对于基于linux的操作系统:由于路径损坏,我遇到了这样的问题,但我能够暂时修复这个问题,我的Git安装立即恢复。
如果您遇到这样的路径问题,请键入下面的命令
export PATH="/usr/bin:/bin:$PATH"
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'。:)
升级到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
**只需添加一个双斜杠(\\),就像上面的代码一样。
推荐文章
- 打开同一目录两次
- 如何从终端/命令行调用VS代码编辑器
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- 如何在Visual Studio代码中重置设置?
- Git拉另一个分支