#!/usr/bin/env bash # One clean commit with NO .jpg in git history (HF rejects raw binaries in any commit). set -euo pipefail cd "$(dirname "$0")" unset GIT_ASKPASS SSH_ASKPASS if [[ ! -f weights/prebackbone_a11_ca.pt ]]; then echo "ERROR: weights/prebackbone_a11_ca.pt missing. Run extract_prebackbone_weights.py first." exit 1 fi if command -v hf >/dev/null 2>&1; then TOKEN="$(hf auth token 2>/dev/null | tr -d '[:space:]')" if [[ -n "${TOKEN}" ]]; then CRED_FILE="${HOME}/.git-credentials" grep -v "huggingface.co" "${CRED_FILE}" 2>/dev/null > "${CRED_FILE}.tmp" || true [[ -f "${CRED_FILE}.tmp" ]] && mv "${CRED_FILE}.tmp" "${CRED_FILE}" echo "https://vinayedula:${TOKEN}@huggingface.co" >> "${CRED_FILE}" chmod 600 "${CRED_FILE}" fi fi git lfs install git lfs track "*.pt" "*.pth" grep -q "^examples/" .gitignore 2>/dev/null || echo "examples/" >> .gitignore git checkout --orphan main-clean git rm -rf --cached . 2>/dev/null || true git add \ .gitattributes \ .gitignore \ app.py \ prebackbone_infer.py \ extract_prebackbone_weights.py \ requirements.txt \ setup.sh \ README.md \ deploy_to_refdiffnet.sh \ git_hf_sync.sh \ fix_hf_binaries.sh \ push_clean_space.sh \ vendor/ \ weights/prebackbone_a11_ca.pt git commit -m "RefDiffNet: A11_CA prebackbone demo (clean history, no images in git)" git branch -M main git remote set-url origin https://huggingface.co/spaces/vinayedula/RefDiffNet echo "==> Force pushing clean history..." git push -f origin main echo "==> Done: https://huggingface.co/spaces/vinayedula/RefDiffNet"