Superjay
Superjay

Reputation: 477

Flutter 'Error: Unable to find git in your PATH' in Windows

I just installed Flutter SDK, And I got an error Error: Unable to find git in your PATH. when I type flutter --version in CMD.

I searched about this and I found some answers, but nothing works.

I installed SDK in D:, so I deleted it and installed it in C:\src, and I set System variable again, but still same.
And I installed Git and tried again, but failed.

I'm using Window 10.

Upvotes: 1

Views: 18817

Answers (6)

Usama Baig
Usama Baig

Reputation: 41

I encountered this issue only in Android Studio, while running Flutter commands in Windows Command Prompt (CMD) worked fine.

To fix this, I simply ran Android Studio as an administrator, and after that, flutter doctor worked inside Android Studio without any issues.

Upvotes: 0

Mahadi Hassan
Mahadi Hassan

Reputation: 310

Solution: If the above methods don't resolve your issue, you can try adding a global Git configuration to make directory paths safe. Run the following command in your CMD:

git config --global --add core.safecrlf '*'

This will add a configuration to ensure that all directory paths are considered safe. After that, try running flutter --version again.

Upvotes: 1

Mohamed Thabet
Mohamed Thabet

Reputation: 81

Add C:\Windows\System32 to your system variable PATH

Upvotes: 1

mahmood nasr
mahmood nasr

Reputation: 1

I was having everything set correctly but I was still facing the error I only had to reopen Android Studio as Administration.. I hope this works for anyone

Upvotes: 0

K D
K D

Reputation: 215

How to Solve “Unable to find git in your PATH” On Flutter?

You need to install Git using the below command line

winget install --id Git.Git -e --source winget

Add this to your PATH variable

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

Do not create a new variable for git but add them as I did one after another separating them by ";"

If you are windows, 10 users. we’ve tried everything but running cmd as Administrator solved my problem. This may be helpful for others.

You can also try by uninstalling and reinstall GIT to solve my problem. You can download 64-bit GIT for windows setup: https://git-scm.com/download/win

FOR WINDOWS: If you chose visual studio code during git installation and have multiple user accounts on windows then all you need to do is uninstall git and reinstall git choosing vim as the default editor, not visual studio code.

You also get a warning when choosing visual studio code during git installation.

Pay attention to that,
For me setting visual studio code as default and having multiple User accounts was the issue.

Thanks FlutterAgency.com for this help. https://flutteragency.com/unable-to-find-git-in-your-path/

Upvotes: -1

Abhijith
Abhijith

Reputation: 2327

Add path of installed git usually it is in following path,check once,the update the path

C:\Program Files\Git\cmd

to your PATH variable

After you added path,still have problem try this

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?

Upvotes: 3

Related Questions