#!/usr/bin/env bash set -euo pipefail base=${1:-} out=${2:-gitdump} [[ -z "$base" ]] && { echo "Usage: $(basename "$0") [outdir]" >&2; exit 1; } mkdir -p "$out/.git" cd "$out" echo "[+] Attempting to mirror .git from $base" wget -q --no-host-directories --cut-dirs=0 -r -np -nH -R "index.html*" "${base%/}/.git/" || true if [[ -d .git ]]; then echo "[+] Found .git directory. Trying to restore working tree." git init >/dev/null 2>&1 || true git reset --hard >/dev/null 2>&1 || true echo "[+] Done. Inspect repo at: $(pwd)" else echo "[!] .git not accessible or download failed." fi