You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PowerShell提示‘git’未被识别为有效命令的问题求助

PowerShell中git命令无法识别的解决办法(已设置环境变量仍无效)

报错信息:

PS C:\Users\akira> git 

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安装路径:找到你的Git安装目录,默认路径通常是C:\Program Files\Git\bin或C:\Program Files\Git\cmd,检查这两个目录下是否存在git.exe文件。
  • 核对环境变量配置:右键「此电脑」→「属性」→「高级系统设置」→「环境变量」,在系统变量的Path项中添加上述两个Git路径(优先用系统变量,避免用户权限导致的加载问题),添加完成后点击所有弹窗的「确定」。
  • 重启PowerShell:环境变量修改后,必须关闭所有已打开的PowerShell窗口,重新打开再执行git命令测试——旧窗口不会加载新的环境变量。
  • 手动执行验证:在PowerShell中输入Git的完整路径测试,比如& "C:\Program Files\Git\bin\git.exe",如果能正常执行,说明是环境变量未生效或配置有误。
  • 检查环境变量加载情况:在新PowerShell窗口执行$env:Path -split ';',查看输出列表中是否包含Git的路径,若没有则重新检查环境变量配置步骤。
  • 调整PowerShell执行策略(可选):执行Get-ExecutionPolicy,若结果为Restricted,执行Set-ExecutionPolicy RemoteSigned并按Y确认,部分严格策略会影响命令识别。

内容的提问来源于stack exchange,提问作者ANS AHMED

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 02:52:34