179

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?

17 Answers 17

209

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)

11
  • 7
    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. Commented Oct 29, 2014 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.
    Commented Mar 25, 2015 at 12:03
  • 1
    Tip: to quickly cut and paste that long honking github path, run the Git Shell and type PATH.
    – Bob Stein
    Commented May 2, 2015 at 12:28
  • 1
    you know, I read the answer, and I still added git.exe to the path :/
    – Ayyash
    Commented Mar 5, 2016 at 9:05
  • 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\<user>\AppData\Local\GitHub\Portab~1\cmd. This will work provided no other file/directory in the GitHub folder also starts with Portab.
    – Brendan
    Commented Dec 9, 2016 at 22:20
182

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;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

7
  • 2
    I have it in both places, so what do I do? ignore the long one?
    – Ayyash
    Commented Mar 5, 2016 at 9:07
  • 1
    What I said in reply it worked for me. give it a try it will work.
    – Adnan Ali
    Commented Mar 5, 2016 at 10:24
  • 4
    If you are using visual studio code or ide with cmd: Don't just close the cmd, restart the entire ide. Commented Nov 17, 2017 at 13:17
  • It did work . Thanks for your answer. You specificity is intelligent. Commented Mar 1, 2018 at 12:13
  • C:\Program Files\Git\ doesn't exist for me. I'm on Windows 10, GitHub Desktop 2.6.1. Commented Jan 6, 2021 at 0:44
44

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

3
  • 4
    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
    Commented Jun 2, 2019 at 20:00
  • 1
    Actually it was for hiding, but i did a bad job over there. Commented Jun 4, 2019 at 5:47
  • 9
    Your stack overflow's username is the same as that text you scribbled.
    – Verma Aman
    Commented Aug 28, 2019 at 14:45
23

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
1
  • 3
    Yeah GHD on Windows 10 64bit, confirmed mine was there as well: C:\Users\<user>\AppData\Local\GitHubDesktop\app-1.0.1\resources\app\git\cmd
    – TSga
    Commented Sep 27, 2017 at 17:05
14

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

11

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

6

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.

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

0
1

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

c:\Program Files (x86)\SmartGit\git\bin\git.exe
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.

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

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.

1
  • That's a bit harsh. Probably not the best solution.
    – Alexander
    Commented Jan 14, 2021 at 21:49
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

0

You don't need to install it on PATH. You need to make sure the command is able to find Git, that I presume is already installed. Ensure the CLI you execute is on the PATH. If you use CMD, you can use something like:

set PATH=%PATH%;C:\Users\%userprofile%\AppData\Local\GitHub\PortableGit_<guid>\cmd\

Now, when you open your terminal again from which you execute npm (I presume you're not executing it from an IDE, because in that case the PATH has to be set to the process launching the IDE or within the IDE itself), and run the npm command of your choice, it should work.

0

In my case the git.exe and git-lfs.exe files were in a different folder (C:\Program Files\Git\cmd\). I showed the new related paths in unity and pushed the button Find System Git. and it worked.

Related picture:

enter image description here

0

this one works fine on Windows

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

It's very important to restart your PC after modifying the Environment PATH to see the effect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.