If you think git-cmd.bat
, all you have to do is set the correct %PATH%
variable before your git commands in the script:
If you do not, here is what you will see:
C:\Users\VonC>git --version 'git' is not recognized as an internal or external command, operable program or batch file.
I have an uncompressed latest portable version of msysgit .
Put somewhere a test.bat
script (so that no force is involved there) with the following contents:
@setlocal @set git_install_root="C:\Users\VonC\prg\PortableGit-1.7.11-preview20120620" @set PATH=%git_install_root%\bin;%git_install_root%\mingw\bin;%git_install_root%\cmd;%PATH% @if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH% @if not exist "%HOME%" @set HOME=%USERPROFILE% @set PLINK_PROTOCOL=ssh REM here is the specific git commands of your script git --version echo %HOME% git config --global --list
Make sure HOME
installed correctly, because git will look for your global git config there.
The result will give you:
C:\Users\VonC>cd prog\git C:\Users\VonC\prog\git>s.bat C:\Users\VonC\prog\git>git --version git version 1.7.11.msysgit.0 C:\Users\VonC\prog\git>echo C:\Users\VonC C:\Users\VonC C:\Users\VonC\prog\git>git config --global --list user.name=VonC
Note: the same script works fine with powershell session.
source share