154

How do I install Git in my PATH when using the GitHub client for Windows?

I'm running into errors because apparently Git is not installed in PATH. For example, using Atom, trying to install the Linter plugin gives this error:

npm ERR! not found: git
npm ERR! 
npm ERR! Failed using git.
npm ERR! This is most likely not a problem with npm itself.
npm ERR! Please check if you have git installed and in your PATH.

Does GitHub for Windows install Git when it installs? (It must, otherwise how does it use Git?) I don't want to double-install it... so how do I just add the Git that's already there to PATH?

Promise Preston
  • 8,732
  • 5
  • 43
  • 70
brentonstrine
  • 17,958
  • 23
  • 61
  • 112

14 Answers14

191

GitHub for Windows does indeed install its own version of Git, but it doesn't add it to the PATH variable, which is easy enough to do. Here's instructions on how to do it:

  1. Get the Git URL

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

    C:\Users\<user>\AppData\Local\GitHub\PortableGit_<guid>\cmd\git.exe
    

    So on your computer, replace <user> with your user and find out what the <guid> is for your computer. (The guid may change each time GitHub updates PortableGit, but they're working on a solution to that.)

    Copy it and paste it into a command prompt (right-click > paste to paste in the terminal) to verify that it works. You should see the Git help response that lists common Git commands. If you see The system cannot find the path specified. Then the URL isn’t right. Once you have it right, create the link to the directory using this format:

    ;C:\Users\<user>\AppData\Local\GitHub\PortableGit_<guid>\cmd
    

    (Note: \cmd at the end, not \cmd\git.exe anymore!)

    On my system, it’s this, yours will be different:

    ;C:\Users\brenton\AppData\Local\GitHub\PortableGit_7eaa494e16ae7b397b2422033as45d8ff6ac2010\cmd
    
  2. Edit the PATH Variable

    Navigate to the Environmental Variables Editor (instructions) and find the Path variable in the “System Variables” section. Click Edit… and paste the URL of Git to the end of that string. Save! It might be easier to pull this into Notepad to do the edit, just make sure you put one semicolon before you paste in the URL. If it doesn't work it’s probably because this path got messed up either with a space in there somewhere (should be no spaces around the semicolon) or a semicolon at the end (semicolons should only separate URLs, no semicolon at beginning or end of string).

If it worked, you should be able to close & reopen a terminal and type git and it will give you that same git help file. Then installing the Linter should work. (Atom > File > Settings > Packages > Linter)

Michael Piefel
  • 14,444
  • 5
  • 65
  • 95
brentonstrine
  • 17,958
  • 23
  • 61
  • 112
  • 5
    Only adding the `\cmd` folder to your `PATH` should be enough. The `git.exe` in that folder probably links through to the `git.exe` in the `\bin` folder. Adding the `\bin` folder could lead to some conflicts between the executables found in there and other executables found in your path environment. – Dennis van der Schagt Oct 29 '14 at 10:21
  • 1
    @brentonstrine please apply @dennisschagt's suggestion properly.Your answer still describes how to use the `\bin` folder instead of the `\cmd` folder, please fix this. – Petrus K. Mar 25 '15 at 12:03
  • Thanks @PetrusKiendys, I just got them switched in my head last time I edited. Should be correct now. – brentonstrine Apr 29 '15 at 16:11
  • Thanks! So that GUID can change?! That's nasty. Also hating that it [makes the PATH so long](http://superuser.com/questions/387619/overcoming-the-1024-character-limit-with-setx). – Bob Stein May 02 '15 at 12:25
  • 1
    Tip: to quickly cut and paste that long honking github path, run the **Git Shell** and type PATH. – Bob Stein May 02 '15 at 12:28
  • 1
    you know, I read the answer, and I still added git.exe to the path :/ – Ayyash Mar 05 '16 at 09:05
  • Note that if you run your command line from a folder ( file-> open cmd/powershell), reopening a command line wont be enough. You will have to re-open that folder in order to refresh the environment variables. – Haim Bendanan Oct 01 '16 at 23:06
  • 6
    As of Dec 2016 it still exists in this directory which changes after each install which is annoying! One workaround however is to use the DOS truncated reference i.e. `PORTAB~1` in your environment variable PATH and it will resolve. e.g. `C:\Users\\AppData\Local\GitHub\Portab~1\cmd`. This will work provided no other file/directory in the GitHub folder also starts with `Portab`. – Brendan Dec 09 '16 at 22:20
  • To expand on Brendan's comment a more generic version would be: ```%USERPROFILE%\AppData\Local\GitHub\Portab~1\cmd``` This ought to work for everyone (usual caveats aside) – user1816847 Jul 21 '17 at 18:55
  • Environment variables instructions for windows 10 don't work anymore. – DrCord Feb 10 '18 at 15:29
  • You are my hero. – Robotnicka Jan 08 '19 at 15:51
  • Please mention that they have to change also the USER VARIABLES also. Thats how it fixes. –  May 24 '19 at 09:02
147

I would like to add one more thing to what the other answers have said. It is not compulsory that path will be:

C:\Users\<user>\AppData\Local\GitHub\PortableGit_<guid>\bin\git.exe

In my computer I did not found Git there.

BUT git and cmd are located in

git.exe

C:\Program Files\Git\bin\git.exe

cmd

C:\Program Files\Git\cmd

To add into PATH:

  • Right-Click on My Computer
  • Click on Advanced System Settings
  • Click on Environment Variables
  • Then, under System Variables, look for the path variable and click edit
  • Add the path to git’s bin and cmd at the end of the string like this:

    ;C:\Program Files\Git\bin\git.exe;C:\Program Files\Git\cmd

OR

;C:\Users\<user>\AppData\Local\GitHub\PortableGit_<guid>\bin;C:\Users\<user>\AppData\Local\GitHub\PortableGit_<guid>\cmd

To verify, restart cmd and type git --version in cmd

ragingasiancoder
  • 615
  • 6
  • 17
Adnan Ali
  • 2,449
  • 4
  • 13
  • 32
35

Thanks everyone who have answered.I have seen all answers and to try to make it easy for everyone

Step 1: Type edit environment and select the option shown

enter image description here

Step 2: Select Path and click on edit

enter image description here

Step 3: In the end add the below statement(you can avoid the first ; if its already there)

;C:\Program Files\Git\bin\git.exe;C:\Program Files\Git\cmd

enter image description here

Step 4:- Click on ok

enter image description here

Step 5 **:- One of the important step which is highlighted by one of the users. thanks to him. Please, **CLOSE command prompt and REOPEN then try to write git.

**

  • Close command prompt and restart before trying the below command

**

Here is the magic

enter image description here

Tarun Dholakiya
  • 801
  • 1
  • 11
  • 16
Gaurav khurana
  • 2,262
  • 1
  • 18
  • 22
  • 2
    So, the freehand scribbling is just meant to highlight that those parts are user-specific, right? Because it's not really hiding anything; it's the same name (with slightly altered formatting) that is affixed to the answer. – SamB Jun 02 '19 at 20:00
  • Actually it was for hiding, but i did a bad job over there. – Gaurav khurana Jun 04 '19 at 05:47
  • 4
    Your stack overflow's username is the same as that text you scribbled. – Verma Aman Aug 28 '19 at 14:45
19

I installed GitHubDesktop on Windows 10 and git.exe is located there:

C:\Users\john\AppData\Local\GitHubDesktop\app-0.7.2\resources\app\git\cmd\git.exe
Adnan Ali
  • 2,449
  • 4
  • 13
  • 32
Samuel Auger
  • 222
  • 2
  • 10
  • 2
    Yeah GHD on Windows 10 64bit, confirmed mine was there as well: C:\Users\\AppData\Local\GitHubDesktop\app-1.0.1\resources\app\git\cmd – TSga Sep 27 '17 at 17:05
12

Git’s executable is actually located in: C:\Users\<user>\AppData\Local\GitHub\PortableGit_<guid>\bin\git.exe

Now that we have located the executable all we have to do is add it to our PATH:

  • Right-Click on My Computer
  • Click Advanced System Settings
  • Click Environment Variables
  • Then under System Variables look for the path variable and click edit
  • Add the path to git’s bin and cmd at the end of the string like this:

;C:\Users\<user>\AppData\Local\GitHub\PortableGit_<guid>\bin;C:\Users\<user>\AppData\Local\GitHub\PortableGit_<guid>\cmd

brentonstrine
  • 17,958
  • 23
  • 61
  • 112
Prabin Tp
  • 708
  • 5
  • 15
12

GitHub for Windows is now GitHub desktop.

If you have GitHub for Windows (before version 1.1), your path should be:

C:\Users\<user>\AppData\Local\GitHub\PortableGit_<guid>\cmd

If you have GitHub Desktop (from version 1.1), your path should be:

C:\Users\<user>\AppData\Local\GitHubDesktop\app-<version>\resources\app\git\cmd

After confirming and copying your path, do the following:

  • Right click on My Computer or This PC
  • Click on Properties
  • Click on Advanced system settings
  • Click on Environment Variables under the Advanced tab
  • Add your path with ; before it in the variable Path
  • Press Ok
  • Use a new terminal
Darlesson
  • 3,864
  • 2
  • 17
  • 23
8

Add

C:\Program Files\Git\bin\git.exe;C:\Program Files\Git\cmd;C:\Windows\System32 

to your PATH variable

Do not create new variable for git but add them as I did one after another separating them by ;

It works for me

Marwa Eltayeb
  • 952
  • 9
  • 19
5

Having searched around several posts. On Windows 10 having downloaded and installed Github for Windows 2.10.2 I found the git.exe in

C:\Users\<user>\AppData\Local\Programs\Git\bin

and the git-cmd.exe in

C:\Users\<user>\AppData\Local\Programs\Git

Please note the change to Programs folder within Local from the above posts.

K7Buoy
  • 836
  • 2
  • 12
  • 20
2

To get this to work I had to combine many of the above answers, to anyone who this might help here is my much simpler process.

If you have Windows 10 just start typing "edit environmental..." and it'll pop up right away. Click path and Edit… then paste the ;C:\Program Files\Git\bin\git.exe;C:\Program Files\Git\cmd at the end of the path already there, don't forget the ; to separate your new github path from the current path.

You do not need the guid but if you want to know how to find it open bash, type git --man-path

2

Updated for the Github Desktop

Search up "Edit the system environment variables" on windows search

  • Click environmental variable on the bottom right corner

  • Find path under system variables and click edit on it

  • Click new to add a new path

  • add this path: C:\Users\yourUserName\AppData\Local\GitHubDesktop\bin\github.exe

To make sure everything is working fine, open cmd, and type github.exe

1

If you use SmartGit on Windows, the executable might be here:

c:\Program Files (x86)\SmartGit\git\bin\git.exe
agoldev
  • 1,426
  • 13
  • 29
1

If you are using vscode's terminal then it might not work even if you do the environment variable thing, test by typing git

Restart vscode, it should work.

  • Having added git to my system path and seeing no effect, this was indeed what sorted this for me. Nice shout! – FTWinston May 26 '19 at 21:32
0

I'm using 2.6.6 version

git Path: C:\Users<USER>\AppData\Local\GitHubDesktop\app-2.6.6\resources\app\git\mingw64\bin

Marcel Pinheiro
  • 343
  • 2
  • 5
-2

To fix a problem, in my case: I checked Git folder under c:\program files\Git. I didn't find git.exe, so delete the Git folder and install it again. Declare them in the environment variables as shown above. the problem will be solved.