37 lines
1.1 KiB
Bash
Executable File
37 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
||
# Configure homelab repo to push to both Gitea (local) and remote (e.g. GitHub)
|
||
# Run once after: git init && git add . && git commit -m "Initial homelab config"
|
||
#
|
||
# Usage: ./setup-git-dual-remote.sh [gitea_url] [remote_url]
|
||
# Example: ./setup-git-dual-remote.sh https://git.zea.lt/USER/homelab.git https://github.com/USER/homelab.git
|
||
|
||
set -e
|
||
|
||
GITEA_URL="${1:?Usage: $0 <gitea_repo_url> <remote_repo_url>}"
|
||
REMOTE_URL="${2:?Usage: $0 <gitea_repo_url> <remote_repo_url>}"
|
||
|
||
cd "$(dirname "$0")"
|
||
|
||
if [[ ! -d .git ]]; then
|
||
echo "Initializing git..."
|
||
git init
|
||
git add .
|
||
git commit -m "Initial homelab infrastructure" || true
|
||
fi
|
||
|
||
# Remove default origin if it exists (e.g. from clone)
|
||
git remote remove origin 2>/dev/null || true
|
||
|
||
# Add origin with dual push URLs – one push goes to both
|
||
git remote add origin "$GITEA_URL"
|
||
git remote set-url --add --push origin "$GITEA_URL"
|
||
git remote set-url --add --push origin "$REMOTE_URL"
|
||
|
||
echo "Dual remote configured."
|
||
echo " Local (Gitea): $GITEA_URL"
|
||
echo " Remote backup: $REMOTE_URL"
|
||
echo ""
|
||
echo "Create both repos first (empty, no readme). Then:"
|
||
echo " git branch -M main"
|
||
echo " git push -u origin main"
|