Unable to find git in your PATH in Flutter commands (solved)

If you face this issue where you get the error “Unable to find git in your PATH” while running flutter commands like flutter doctor or flutter pub get then here’s the fix for it.

Unable to find git in your PATH

This happens because of a security update from git where Git now checks for ownership of the folder trying to ensure that the folder you are using Git in has the same user as the owner as your current user account.

Git considers all repos as unsafe be default on Windows because of this security update. You can read more about it here – Git Security Issue: CVE-2022-24765

To fix this, we need to mark our repos as safe using the following command:

git config --global --add safe.directory '*'

Restart your terminals and VS Code after running this command. This should fix the issue

If you don’t want to mark all the repos as safe, then you can mark only the flutter repo as safe by passing the flutter path instead of *

git config --global --add safe.directory C:\Users\someUser\flutter\.git\

Conclusion

The above fix will work if you have git installed along with it added to PATH environment variable.

If you don’t have git installed, then install it and make sure that the git folder’s path is mentioned in the PATH environment variable.

Ranjith kumar
5 3 votes
Article Rating
Subscribe
Notify of
guest

3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Gai
Gai
1 year ago

Amazing! I did it!!
I totally gave up to fix this problem.
I hope your kind advise will help someone in trouble like me .
I really appreciate u!
from Japan

Last edited 1 year ago by Gai
Jayflo
Jayflo
1 year ago

Restart your system, if you don’t know how the error came up.