3

I've just tried to install Flutter on windows 10. When I try to run a flutter command (flutter doctor), I'm getting

Error: Unable to find git in your PATH.

I have set the path to both git and flutter and tried adding the following to path

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

How can I resolve this???

Simeon
  • 848
  • 1
  • 11
  • 34
  • Does this answer your question? [Error: unable to find git in your PATH on windows cmd](https://stackoverflow.com/questions/65446923/error-unable-to-find-git-in-your-path-on-windows-cmd) – Lal Krishna Jun 17 '23 at 07:06

7 Answers7

4

Go to my flutter installation folder and inside flutter/bin edit the flutter.bat file using a text editor and remove the line (Line 33 in mine) that says

IF EXIST "%mingit_path%" SET PATH=%PATH%;%mingit_path%

The code should look like this on those lines

REM If available, add location of bundled mingit to PATH 
SET mingit_path=%FLUTTER_ROOT%\bin\mingit\cmd

REM Test if Git is available on the Host
where /q git || ECHO Error: Unable to find git in your PATH. && EXIT /B 1

Save and Run flutter doctor and everything should work fine.

I guess its something to do with the path variables being confused.

Denver Shenal
  • 311
  • 2
  • 9
2

You could try reinstalling Git with "Use Git and optional unix tools from the command prompt" selected in the installer.

This would add git and the unix tools to the path. You may have installed with only 'Use Git from Bash only' selected?

Simeon
  • 848
  • 1
  • 11
  • 34
1

Find the flutter.bat in your flutter folder which should be inside flutter/bin and edit the flutter.bat using your text editor.

Remove the below line from the file (Mine was Line 33)

IF EXIST "%mingit_path%" SET PATH=%PATH%;%mingit_path%

The file should look like this after you remove it

REM If available, add location of bundled mingit to PATH 
SET mingit_path=%FLUTTER_ROOT%\bin\mingit\cmd

Save and Run flutter doctor and everything should work fine.

I guess its something to do with the path variables being confused.

Before

After

Denver Shenal
  • 311
  • 2
  • 9
0

Set the path up to bin

 C:\Program Files\Git\bin

then try

git --version

if still not working, reinstall git

check these two threads for the further issues SO GH

Ajay Tom George
  • 1,890
  • 1
  • 14
  • 26
0

It turns out I didn't have git installed

https://git-scm.com/downloads

https://git-scm.com/downloads

MosesAyo
  • 323
  • 2
  • 10
0

In my case, I have installed new version from Git official website. (Git-2.41.0).

But the flutter has a git with different version: 2.15.1.windows.2.1.g603511c649. Maybe that could be the reason.

Steps I followed to solve my issue:

  • Run command: where git. This will list out all the existing git paths.
  • Remove all git entries except C:\flutter\bin\mingit\cmd from Environment Path variable. (If you don't have this variable, add it.).

Original Answer: https://stackoverflow.com/a/76495083/4061501

Lal Krishna
  • 15,485
  • 6
  • 64
  • 84
0

I tried the other fix that modified flutter.bat but those did not work for me. Find your shared.bat and manually set the git_exists to true.

C:\tools\flutter\bin\internal\shared.bat

SET git_exists=true
2>NUL (
  PUSHD "%flutter_root%"
  FOR /f %%r IN ('git rev-parse HEAD') DO (
    SET git_exists=true
    SET revision=%%r
  )
  POPD
)

You can set the variable to true or add a SET git_exists=true after the block.

Dave Horner
  • 405
  • 5
  • 10