#!/bin/bash # ───────────────────────────────────────────── # git-sync.sh · Commit & push all changes # to Gitea. Run this whenever you update files. # # Usage: # ./git-sync.sh (auto message) # ./git-sync.sh "My message" (custom message) # ───────────────────────────────────────────── set -e BRANCH="main" cd "$(dirname "$0")" # ── Check we're in a git repo if [ ! -d ".git" ]; then echo "❌ No git repo found. Run ./git-setup.sh first." exit 1 fi # ── Check there's anything to sync if git diff --quiet && git diff --cached --quiet && [ -z "$(git status --porcelain)" ]; then echo "✅ Nothing to sync — everything is already up to date." exit 0 fi # ── Commit message if [ -n "$1" ]; then MSG="$1" else MSG="Sync: $(date '+%Y-%m-%d %H:%M:%S')" fi echo "" echo "📦 Files changed:" git status --short echo "" git add -A git commit -m "$MSG" echo "" echo "⬆️ Pushing to origin/$BRANCH …" git push origin "$BRANCH" echo "" echo "✅ Synced successfully at $(date '+%H:%M:%S')" echo ""