windowsfluttergitpath-variables

Flutter on Windows: "Unable to find git in your PATH" if terminal is not in admin mode


I eventually solved this issue (see here) but wanted to share it here so that more people see it.

Issue is that after installing Flutter on Windows, you try to run flutter doctor and get 'Unable to find git in your PATH'. This however does not happen if you are in Admin mode.

Steps to reproduce Follow all steps to install Flutter on Windows, including installing Git before hand

Make sure that git works if you type it into Powershell as a regular user. If not put the C:\Program Files\Git\cmd (or your equivalent) folder into your Windows PATH Open up Power shell as a regular / non-admin user then type flutter doctor -v. This causes the error: Error: Unable to find git in your PATH.

Now try opening in Admin mode and doing the same - it should work this time.


Solution

  • I saw a comment at the very bottom of this page, that suggested marking all your repos as 'safe' via

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

    Not sure what the implication of doing so is but I went ahead and did it and now things are working properly!

    Prior to this I had tried to make the flutter folder safe via:

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

    but this hadn't worked.