This one has caught me out a couple of times, it’s the kind of issue that you fix and forget about it for a few years until the need arises to move to a new machine.
Here’s the scenario:
Git for Windows is installed and you can use both the GUI and the Bash to exercise Git control over your local repositories.
You install GitHub Desktop and successfully connect to GitHub and import your repositories from GitHub. Windows PowerShell is chosen as the Shell of choice in File > Options > Advanced.
I tend only to use GitHub Desktop to open the repositories in Windows Powershell by selecting Repository > Open in PowerShell. This is where it falls over for me, a warning is returned stating “Unable to locate Git”.
We already know that Git is installed because we’re using it in the Bash, so what’s the problem?
The issue seems to stem from GitHub Desktop installing in the AppData directory by default, rather than C:\Program Files, something to do with portability (C:\Users\joebloggs\AppData\Local\GitHubDesktop).
What’s the solution?
For my system I found the resolution hidden in a Stackoverflow post:
- Go to Start
- Start typing ‘Environment Variables’
- Click on the Environmental Variables button at the bottom
- Down in the System Variables section, double-click Path
- Click the New button in the top right corner
- Add this path: C:\Program Files\Git\bin\ then click the enter key
- Add another path: C:\Program Files\Git\cmd
- Close & re-open the console if it’s already open