GitHub Desktop. Git not recognised when installed

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”.

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:

  1. Go to Start
  2. Start typing ‘Environment Variables’
  3. Click on the Environmental Variables button at the bottom
  4. Down in the System Variables section, double-click Path
  5. Click the New button in the top right corner
  6. Add this path: C:\Program Files\Git\bin\ then click the enter key
  7. Add another path: C:\Program Files\Git\cmd
  8. Close & re-open the console if it’s already open