Files
2026-05-09 11:16:45 +00:00

50 lines
1.8 KiB
Batchfile

@echo off
setlocal EnableDelayedExpansion
set "REPO_URL=https://zerolands.duckdns.org/git/D3SXX/Minecraft-Server-1.21.1-Mods.git"
set "BRANCH=main"
:: ─── Check / install git ─────────────────────────────────────────────────────
where git >nul 2>&1
if %errorlevel% neq 0 (
echo git not found. Installing via winget...
winget install --id Git.Git -e --source winget
if %errorlevel% neq 0 (
echo ERROR: winget failed to install git. Install git manually and re-run.
pause
exit /b 1
)
:: Reload PATH so git is available in the same session
for /f "tokens=*" %%i in ('where git 2^>nul') do set "GIT_EXE=%%i"
if "!GIT_EXE!"=="" (
echo git was installed but is not yet on PATH. Please restart this script.
pause
exit /b 1
)
)
:: ─── Move to the directory containing this script ────────────────────────────
cd /d "%~dp0"
:: ─── Initialise repo if .git is missing ──────────────────────────────────────
if not exist ".git\" (
echo Initialising git repository...
git init
git remote add origin "%REPO_URL%"
) else (
git remote set-url origin "%REPO_URL%" 2>nul || git remote add origin "%REPO_URL%"
)
:: ─── Full reset ────────────────────────────────
echo Fetching latest mods from %REPO_URL% ...
git fetch --all --prune
echo Resetting to origin/%BRANCH% ...
git checkout -B "%BRANCH%" "origin/%BRANCH%" --
git reset --hard "origin/%BRANCH%"
git clean -fd
echo.
echo Mods updated successfully.
pause