From 01bf477860e9bf14fde52d1e18d392c196a1e147 Mon Sep 17 00:00:00 2001 From: antonov Date: Wed, 5 Aug 2026 21:31:24 +0300 Subject: [PATCH] Add Windows CMD restore script --- git-restore-zip.bat | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 git-restore-zip.bat diff --git a/git-restore-zip.bat b/git-restore-zip.bat new file mode 100644 index 0000000..4c781d0 --- /dev/null +++ b/git-restore-zip.bat @@ -0,0 +1,32 @@ +@echo off +setlocal enabledelayedexpansion +:: Restore a git mirror backup into a target repository. +:: Works on Windows (CMD). + +if "%~1"=="" ( + echo Usage: %~nx0 ^ ^ + exit /b 1 +) + +set "ZIP=%~1" +set "TARGET=%~2" +set "WORK_DIR=.tmp_restore_mirror" + +if not exist "%ZIP%" ( + echo Error: file not found: %ZIP% + exit /b 1 +) + +echo [1/3] Extracting %ZIP% ... +mkdir "%WORK_DIR%" >nul 2>&1 +powershell -NoProfile -Command "Expand-Archive -Path '%ZIP%' -DestinationPath '%WORK_DIR%' -Force" + +echo [2/3] Pushing all refs to %TARGET% ... +pushd "%WORK_DIR%" +git remote set-url origin "%TARGET%" +git push --mirror +popd + +echo [3/3] Done. Repository restored at %TARGET% + +rmdir /s /q "%WORK_DIR%" >nul 2>&1