GitHub for Windows doesn't put Git in the PATH by default. If you'd like your Node.js command prompt to have the git
command available by default, simply edit your nodevars.bat
file. By default, this is in C:\Program Files\nodejs\
. You will have to run your text editor in an administrative context for this to work.
Replace this line in your nodevars.bat
file:
set PATH=%APPDATA%\npm;%~dp0;%PATH%
With these thre lines:
for /F %%A in ('"dir /s /b /OD %userprofile%\appdata\local\git.exe"') do set gitPath=%%A\..
IF NOT EXIST "%gitPath%\git.exe" SET gitPath=%gitPath%\..\cmd
set PATH=%APPDATA%\npm;%~dp0;%PATH%;%gitPath%
That will set a variable called %gitPath%
with the location of git.exe
, and then append it at the end of your path in the Node.js command prompt. Because of the /OD switch, it will use the version of Portable Git whose folder has the latest modified date. If Portable Git is not found, you will get a harmless extra ;
in the %path%
.
Updated March 2016 due to change in GitHub for Windows to store
git.exe
undercmd
subfolder.