zkt25/sk1/remove-app.sh

30 lines
1.1 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
# ─── CONFIGURATION ─────────────────────────────────────────────────
GIT_REMOTE_URL="https://af585fp_ftp:P32ubNLJPhnX_ftp@antonin.filippi.website.tuke.sk/plesk-git/exam-app"
BRANCH="master" # or "main" depending on your repo
# ─────────────────────────────────────────────────────────────────
# Prerequisites
command -v git >/dev/null 2>&1 || { echo "Error: git not found"; exit 1; }
# 1) Create a temporary directory
TMPDIR=$(mktemp -d)
echo "→ Cloning into $TMPDIR"
git clone --branch "$BRANCH" --single-branch "$GIT_REMOTE_URL" "$TMPDIR"
# 2) In this clone, remove all tracked files
cd "$TMPDIR"
git rm -r *
# 3) Commit and force push
git commit -m "Cleanup remote httpdocs"
git push --force origin "$BRANCH":"$BRANCH"
# 4) Cleanup
cd -
rm -rf "$TMPDIR"
echo "✅ Remote cleared. Your local repository has not been modified."