-
-
Save rajeshkumaravel/613fe8214cf56261e3fc4a83fd0dd18d to your computer and use it in GitHub Desktop.
Quick install Git for Windows with batch script. Include the git*.exe install executable in the same directory as this script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: Copyright (C): 2017 Pat Migliaccio | |
:: [email protected] | |
:: | |
:: LICENSE: MIT | |
:: | |
:: File: install-git.bat | |
:: | |
:: Batch file for a quick install of Git for Windows | |
:: Include the git*.exe install executable | |
:: in the same directory as this script. | |
:: | |
:: Usage: | |
:: .\install-git [path] | |
:: | |
:: Arguments: | |
:: path : Directory to install to (defaults to "C:\Program Files\Git") | |
:: | |
:: Repository: https://gist.github.com/patmigliaccio/c3fba12e4b6a62db70ad3ef791e29302 | |
:: License: MIT | |
@echo off | |
set installDir=%1 | |
if [%1]==[] set installDir="C:\Program Files\Git" | |
set installDir=%installDir:"=% | |
( | |
echo [Setup] | |
echo Lang=default | |
echo Dir=%installDir% | |
echo Group=Git | |
echo NoIcons=0 | |
echo SetupType=default | |
echo Components=icons,ext\reg\shellhere,assoc,assoc_sh | |
echo Tasks= | |
echo PathOption=Cmd | |
echo SSHOption=OpenSSH | |
echo CRLFOption=CRLFAlways | |
echo BashTerminalOption=ConHost | |
echo PerformanceTweaksFSCache=Enabled | |
echo UseCredentialManager=Enabled | |
echo EnableSymlinks=Disabled | |
echo EnableBuiltinDifftool=Disabled | |
) > config.inf | |
for /r %%f in (git*.exe) do ( | |
call set file="%%f" | |
@echo on | |
@echo %%f | |
@echo off | |
) | |
if [%file%]==[] ( | |
@echo on | |
@echo Error finding "git*.exe" install executable. File may not exist or is not named with the "git" prefix. | |
exit /b 2 | |
) | |
@echo on | |
@echo Installing.. | |
@echo off | |
%file% /VERYSILENT /LOADINF="config.inf" | |
if errorlevel 1 ( | |
@echo on | |
if %errorLevel% == 1 ( echo Error opening %file%. File may be corrupt. ) | |
if %errorLevel% == 2 ( echo Error reading %file%. May require elevated privileges. Run as administrator. ) | |
exit /b %errorlevel% | |
) | |
del config.inf | |
net session >nul 2>&1 | |
if %errorLevel% == 0 ( | |
pathman /as "%PATH%;%installDir%/cmd" | |
exit 0 | |
) else ( | |
@echo on | |
echo SYSTEM PATH Environment Variable may not be set, may require elevated privileges. Run as administrator if it doesn't already exist. | |
exit /b 0 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment