diff --git a/git-restore-zip-macos.sh b/git-restore-zip-macos.sh new file mode 100644 index 0000000..3cc4cd9 --- /dev/null +++ b/git-restore-zip-macos.sh @@ -0,0 +1,32 @@ +# Restore a git mirror backup into a target repository. +# Works on macOS. + +set -euo pipefail + +if [ $# -lt 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +ZIP="$1" +TARGET="$2" +WORK_DIR=".tmp_restore_mirror" + +if [ ! -f "$ZIP" ]; then + echo "Error: file not found: $ZIP" + exit 1 +fi + +cleanup() { rm -rf "$WORK_DIR"; } +trap cleanup EXIT + +echo "[1/3] Extracting $ZIP ..." +mkdir -p "$WORK_DIR" +unzip -q "$ZIP" -d "$WORK_DIR" + +echo "[2/3] Pushing all refs to $TARGET ..." +cd "$WORK_DIR" +git remote set-url origin "$TARGET" +git push --mirror + +echo "[3/3] Done. Repository restored at $TARGET"