我刚刚尝试在 Linux 上安装 Flutter,当我尝试运行 flutter 命令(flutter doctor)时,我得到了
Error: Unable to find git in your PATH.
我该如何解决这个问题?
添加
C:\Program Files\Git\bin\git.exe;C:\Program Files\Git\cmd;C:\Windows\System32
到您的 PATH 变量
不要为 git 创建新变量,而是像我一样一个接一个地添加它们,用 ;
分隔它们使用以下命令安装它。
sudo apt-get install git
我在 Windows 10 上遇到了同样的问题。我已经尝试了所有方法,但以管理员身份运行 cmd 解决了我的问题。
只需将
C:\Windows\System32
添加到您的系统变量PATH。
它有效
这是我通过 chocolatey 安装的 Windows 11 64 位 flutter 3.7.3 解决方案。它只是与强制的 git 安全设置有关,该设置可以检测 flutter 存储库的可疑所有权。只需将 flutter 基目录添加到 git 目录异常列表中即可:
git config --global --add safe.directory C:/tools/flutter-base-dir
更改 flutter base 目录的所有权