PowerShell执行git.init提示命令未识别报错如何解决
问题场景
跟随视频教程操作上传GitHub项目时出现命令执行报错,报错界面如下:
终端输出的完整报错信息:
PS C:\Users\BRQL\Documents\Github vscode> git.init git.init: The term 'git.init' 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.init + +~~~~~~~~~~ + Category Info ~ : ObjectNotFound: (git.init:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
报错原因
命令书写格式错误。Git初始化本地仓库的标准命令为git init,git(主命令)和init(子参数)之间必须用空格分隔,不能写成点号连接的git.init。点号写法会让PowerShell将git.init识别为独立的可执行程序,系统中不存在对应程序时就会抛出命令找不到的异常。
解决方法
- 清空当前终端输入内容,直接输入正确的初始化命令执行:
git init
- 若执行上述命令仍提示找不到git命令,先输入
git --version做校验:- 能正常返回Git版本号:重启终端/VS Code后重试即可
- 提示命令不存在:先下载安装Git客户端,安装过程中务必勾选
Add Git to system PATH选项,安装完成后重启终端再执行对应操作。
内容的提问来源于stack exchange,提问作者alpheus salvador
相关产品推荐
相关产品推荐

