为什么 VSCode 无法识别 git?

时间:2021-05-08 14:14:20

标签: git github visual-studio-code

我正在尝试将我的 React 应用程序上传到我的 github,但 VS 代码无法识别 Git 命令。

我在 PC 上安装了 Git。 git的路径是正确的,我检查了多次。我已经通过 vs 代码终端安装了 gh 页面。我还向 package.json 添加了必需的更改。现在,当我在 vs 代码终端中运行 git init 时,它会抛出“git”不是可识别命令的错误。为什么会发生这种情况,有人可以帮忙吗。

这是 vs 代码中的 git 路径 - "git.path": "C:/Program Files/Git/bin/git.exe" 是正确的。

Git Enabled 也被选中。

package.json 在第一个 {}“主页”下编辑:“http://greardrear.github.io/messenger”,添加并在脚本下添加“predeploy”:“npm run build”, "deploy": "gh-pages -d build", .

当我尝试执行“git init”或“git remote add origin”时,我在 vs 终端中收到此消息:

 git : The term 'git' is not recognized as the name of a cmdlet, function, script file, or operable program.  
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.    
At line:1 char:1
+ git
+ ~~~
    + CategoryInfo          : ObjectNotFound: (git:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException 

我该如何解决这个问题?

附注。我已经尝试了所有我能找到的这个问题的“修复”。我也尝试将路径更改为 "git.path": "C:/Program Files/Git/git-bash.exe" 这也不起作用。

1 个答案:

答案 0 :(得分:1)

根据我的 previous answer 的评论,首先检查简单地重新启动 PC 是否有帮助。

Powershell 可能需要它来完全识别 Windows 安装的 Git。
那个或re-install Git for Windows again