如何在 Flutter 上解决“Unable to find git in your PATH”?

问题描述 投票:0回答:7

我刚刚尝试在 Linux 上安装 Flutter,当我尝试运行 flutter 命令(flutter doctor)时,我得到了

Error: Unable to find git in your PATH.

我该如何解决这个问题?

git flutter flutter-dependencies flutter-test
7个回答
35
投票

添加

C:\Program Files\Git\bin\git.exe;C:\Program Files\Git\cmd;C:\Windows\System32 

到您的 PATH 变量

不要为 git 创建新变量,而是像我一样一个接一个地添加它们,用 ;

分隔它们

31
投票

使用以下命令安装它。

sudo apt-get install git


12
投票

我在 Windows 10 上遇到了同样的问题。我已经尝试了所有方法,但以管理员身份运行 cmd 解决了我的问题。


10
投票

只需将

C:\Windows\System32
添加到您的系统变量PATH。 它有效


9
投票

这是我通过 chocolatey 安装的 Windows 11 64 位 flutter 3.7.3 解决方案。它只是与强制的 git 安全设置有关,该设置可以检测 flutter 存储库的可疑所有权。只需将 flutter 基目录添加到 git 目录异常列表中即可:

git config --global --add safe.directory C:/tools/flutter-base-dir

或者使用 fix unsafe git repository

更改 flutter base 目录的所有权

5
投票

我也遇到了同样的问题,因为我的系统没有安装 git。所以我从

https://git-scm.com/downloads

3
投票

注意: 此解决方案仅适用于 Windows。

将这些变量添加到环境变量中的Path: (如何添加到路径阅读:

https://stackoverflow.com/a/72341522/8890476
  1. C:\src 乱入
  2. C:\Windows\System32
  3. C:\Windows\System32\WindowsPowerShell 1.0
  4. C:\Program Files\Git 中\git.exe
C:\Program Files\Gi
© www.soinside.com 2019 - 2024. All rights reserved.