@echo off setlocal EnableDelayedExpansion :: Configuration set "REPO_URL=https://github.com/Teddy-1024/minecraft_server_zombie.git" set "SYNC_FOLDERS=mods config kubejs defaultconfigs scripts resources patchouli_books pfm modernfix" :: Clear screen and show header cls echo Minecraft Server Sync Tool echo ======================== echo. :: Check if git is installed where git >nul 2>&1 if %ERRORLEVEL% NEQ 0 ( echo Git is not installed or not in PATH. echo Please install Git from https://git-scm.com/downloads pause exit /b 1 ) :: Create a temporary directory for the git operations set "TEMP_GIT_DIR=%TEMP%\mc_git_sync" if exist "%TEMP_GIT_DIR%" rd /s /q "%TEMP_GIT_DIR%" mkdir "%TEMP_GIT_DIR%" cd "%TEMP_GIT_DIR%" :: Initialize git repo git init git remote add origin "%REPO_URL%" git config core.sparseCheckout true :: Set up sparse checkout for selected folders del /q .git\info\sparse-checkout 2>nul for %%F in (%SYNC_FOLDERS%) do ( echo %%F/>> .git\info\sparse-checkout ) :: Fetch latest content git fetch --depth 1 origin main git checkout main :: Copy contents to instance folders for %%F in (%SYNC_FOLDERS%) do ( if exist "%TEMP_GIT_DIR%\%%F" ( echo Syncing %%F... :: Create target directory if it doesn't exist if not exist "%~dp0%%F" mkdir "%~dp0%%F" :: Copy contents, updating only newer files robocopy "%TEMP_GIT_DIR%\%%F" "%~dp0%%F" /E /XO /NP /NFL /NDL ) ) :: Clean up cd "%~dp0" rd /s /q "%TEMP_GIT_DIR%" echo. echo Sync completed successfully! echo. echo This sync has: echo - Updated all tracked files from the repository echo - Preserved your local untracked files echo. pause