@echo off setlocal :: Define variables set "GIT_URL=https://github.com/git-for-windows/git/releases/latest/download/PortableGit-2.49.0-64-bit.7z.exe" set "GIT_ARCHIVE=PortableGit.7z.exe" set "SCRIPT_DIR=%~dp0" set "EXTRACT_DIR=%SCRIPT_DIR%gitportable" :: Check if Git is available in the PATH where git >nul 2>nul if %errorlevel%==0 ( echo Git is already installed and available in PATH. goto :EOF ) :: Check if gitportable folder already exists if exist "%EXTRACT_DIR%\" ( echo 'gitportable' folder already exists. Skipping download. goto :EOF ) :: Download Portable Git echo Downloading Portable Git... powershell -Command "Invoke-WebRequest -Uri '%GIT_URL%' -OutFile '%SCRIPT_DIR%%GIT_ARCHIVE%'" :: Create extraction directory mkdir "%EXTRACT_DIR%" :: Extract Portable Git echo Extracting Portable Git... "%SCRIPT_DIR%%GIT_ARCHIVE%" -o"%EXTRACT_DIR%" -y :: Cleanup del "%SCRIPT_DIR%%GIT_ARCHIVE%" echo Done. Portable Git is ready in: %EXTRACT_DIR% pause