27

I was following this guide here on how to add Git to my Path variable so I can use it from the command line (Not just Git Bash).

Installing Git in PATH with GitHub client for Windows

To quote an answer, Git was supposedly located here

Get the Git URL

We need to get the url of the Git \cmd directory your computer. Git is located here:

C:\Users\\AppData\Local\GitHub\PortableGit_\bin\git.exe

I opened File Explorer and went to the directory C:\Users\AppData\Local\

Under the view tab, I have Hidden Items checked. I cannot see a GitHub folder listed. In the search bar, I appended GitHub to the end of the directory path and got the following message

Windows can't find 'C:\Users\username\AppData\Local\GitHub'. Check the spelling and try again.

I'm trying to add Git to my environment path variable, but can't find where git is located.

In Git Bash, I was able to try which git where I got /bin/git

But I'm not sure how I can find what to put in under environment variable.

Doing a random search, I actually found that the Git folder was located here

C:\ProgramFiles(x86)\Git

But what am I supposed to enter for the path variable? This is different from the answer in the other question.

Community
  • 1
  • 1
Richard Hamilton
  • 25,478
  • 10
  • 60
  • 87

4 Answers4

16

Just add the path to the command. This was the path to add to the end of the windows PATH.

C:\Program Files\Git\bin\

Now we should be able to find git.exe by typing

git
Ben Paz
  • 241
  • 3
  • 11
7

It turns out Git was being sneaky!

It was supposed to be installed in AppData/Local, but was actually installed in the Program Files(x86) directory.

I added this to my Path variable after a semicolon

C:\Windows\Program Files(x86)\Git\bin\git.exe

And magically, I can run git again.

Richard Hamilton
  • 25,478
  • 10
  • 60
  • 87
  • 3
    I'm glad that this worked for you, but you should be aware that you've (probably) found a separate Git installation. Git and GitHub are separate and largely unrelated. GitHub for Windows ships its own embedded version of Git, and the one in `Program Files (x86)` is almost certainly from something else (possibly [msysgit](https://msysgit.github.io/)). – ChrisGPT was on strike Jul 01 '15 at 16:57
  • 2
    Have you also installed [GitHub for Windows](https://windows.github.com/)? It's certainly not required, but the guide you were following was for that product, not for Git from git-scm.com. – ChrisGPT was on strike Jul 01 '15 at 17:59
  • 1
    You mean you added that in to the Control Panel > System > Advanced > Environment Variables and then edited the Path and put it behind the line with a ; before it? – Nuri Ensing Sep 03 '15 at 09:25
3

For Windows 7 using GIT 2.7.2 I used this in the path under environment variables:

;C:\Program Files\Git\bin;C:\Program Files\Git\bin\cmd. I then typed git --version from a command prompt and got:

git version 2.7.2.windows.1
James Drinkard
  • 15,342
  • 16
  • 114
  • 137
1

Another way is found in this place https://stackoverflow.com/a/34767523/5842689

the best thing is you can test if work in cmd.

"o verify, restart cmd and type git --version in cmd"

it works for me cause the real path in my case (Win10 x64)is C:\Program Files (x86)\Git\bin\git.exe

Community
  • 1
  • 1
Zulder
  • 11
  • 3