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?
当前回答
我只需要从这个链接https://git-scm.com/download/win为windows安装git就可以了
不需要设置环境变量或路径。
背景: 我已经安装了VS Code,和github桌面,我克隆的回购使用github桌面。
当我打开repo时,使用VS Code,我看到了这个错误。
我通过为windows安装git来解决这个问题。
其他回答
Visual Studio Code只是在PATH中查找git。为了简单起见,许多UI客户端附带了“可移植Git”,并且没有将Git添加到路径中。
如果您将现有的git客户端添加到您的PATH(以便它可以找到git.exe), Visual Studio Code应该启用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
**只需添加一个双斜杠(\\),就像上面的代码一样。
这样做:
1. File > Preferences > setting
2. In search type -> git path
3. Now scroll down a little > you will see "Git:path" section.
4. Click "Edit in settings.json".
5. Now just paste this path there "C:\\Program Files\\Git\\mingw64\\libexec\\git-core\\git.exe"
重启VSCode,在VSCode中打开新终端,尝试“git版本”
如果仍然存在问题:
1. Inside terminal click on terminal options (1:Poweshell)
2. Select default shell
3. Select bash
打开新终端,并将终端选项改为2:Bash 再次尝试“git版本”-这应该工作:)
Open
C:\Users\nassim\AppData\Roaming\Code\User\settings.json
注释任何Git行:
// ...
// "git-graph.integratedTerminalShell": "E:\\Apps\\Git\\bin\\bash.exe",
// "git.path": ""
//...
将“git.exe”添加到操作系统路径下。
注意:修复这个Git错误也修复了npm错误。因为它们都是在路径中定义的,如果一个失败了,其余的也会失败。
我在升级到macOS v10.15 (Catalina)后遇到了这个问题。
问题解决方法如下:
1.
从终端找到Git的位置:
which git
2.
在设置文件中添加Git的位置和你的位置:
settings.json
"git.path": "/usr/local/bin/git",
根据你的平台,用户设置文件(settings.json)位于这里: Windows % APPDATA % \ \用户\ settings.json代码 macOS $HOME/Library/Application Support/Code/User/settings.json Linux $ HOME / config /代码/ User / settings.json
推荐文章
- 打开同一目录两次
- 如何从终端/命令行调用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拉另一个分支