From d978491bfc9fc6b8174582d28f9da7d7bddef9ec Mon Sep 17 00:00:00 2001 From: antonov Date: Wed, 5 Aug 2026 21:31:27 +0300 Subject: [PATCH] Add Windows PowerShell restore script --- git-restore-zip.ps1 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 git-restore-zip.ps1 diff --git a/git-restore-zip.ps1 b/git-restore-zip.ps1 new file mode 100644 index 0000000..1ad6480 --- /dev/null +++ b/git-restore-zip.ps1 @@ -0,0 +1,34 @@ +param( + [Parameter(Mandatory = $true, Position = 0)] + [string]$Zip, + + [Parameter(Mandatory = $true, Position = 1)] + [string]$Target +) + +$ErrorActionPreference = "Stop" +$WorkDir = ".tmp_restore_mirror" + +if (-not (Test-Path $Zip)) { + Write-Host "Error: file not found: $Zip" + exit 1 +} + +try { + Write-Host "[1/3] Extracting $Zip ..." + New-Item -ItemType Directory -Force -Path $WorkDir | Out-Null + Expand-Archive -Path $Zip -DestinationPath $WorkDir -Force + + Write-Host "[2/3] Pushing all refs to $Target ..." + Push-Location $WorkDir + git remote set-url origin $Target + git push --mirror + Pop-Location + + Write-Host "[3/3] Done. Repository restored at $Target" +} +finally { + if (Test-Path $WorkDir) { + Remove-Item -Recurse -Force $WorkDir + } +}