param( [Parameter(Mandatory = $true, Position = 0)] [string]$Url, [Parameter(Position = 1)] [string]$Output = "repo.zip" ) $ErrorActionPreference = "Stop" $WorkDir = ".tmp_git_mirror" try { Write-Host "[1/3] Cloning mirror of $Url ..." git clone --mirror $Url $WorkDir Write-Host "[2/3] Creating $Output with maximum compression ..." Compress-Archive -Path "$WorkDir\*" -DestinationPath $Output -CompressionLevel Optimal -Force $Size = [math]::Round((Get-Item $Output).Length / 1MB, 2) Write-Host "[3/3] Done: $Output ($Size MB)" } finally { if (Test-Path $WorkDir) { Remove-Item -Recurse -Force $WorkDir } }