From f877f2eeeb75334dce03ef9caa714fa9ae6298c1 Mon Sep 17 00:00:00 2001 From: antonov Date: Wed, 5 Aug 2026 21:28:37 +0300 Subject: [PATCH] Add Linux script --- git-mirror-zip.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 git-mirror-zip.sh diff --git a/git-mirror-zip.sh b/git-mirror-zip.sh new file mode 100644 index 0000000..e87b066 --- /dev/null +++ b/git-mirror-zip.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Clone a git repo as a full mirror and pack it into a zip archive. +# Works on Linux and macOS. + +set -euo pipefail + +if [ $# -lt 1 ]; then + echo "Usage: $0 [output.zip]" + exit 1 +fi + +URL="$1" +OUT="${2:-repo.zip}" +WORK_DIR=".tmp_git_mirror" + +# Cleanup on exit +cleanup() { rm -rf "$WORK_DIR"; } +trap cleanup EXIT + +echo "[1/3] Cloning mirror of $URL ..." +git clone --mirror "$URL" "$WORK_DIR" + +echo "[2/3] Creating $OUT with maximum compression ..." +(cd "$WORK_DIR" && zip -9 -r "../$OUT" .) + +SIZE=$(du -m "$OUT" | cut -f1) +echo "[3/3] Done: $OUT (${SIZE} MB)"