#!/bin/sh
# git-setup-mirrors - Set up multiple push URLs for mirroring
#
# Usage: git-setup-mirrors <profile> <repo-name>
# profile: krisyotam, khr1st, or laelyotam
# repo-name: name of the repository (without .git)
#
# Example: git-setup-mirrors krisyotam my-project
#
# This adds multiple push URLs to 'origin' so a single 'git push'
# pushes to all configured mirrors.
set -e
PROFILE="$1"
REPO="$2"
usage() {
echo "Usage: git-setup-mirrors <profile> <repo-name>"
echo ""
echo "Profiles:"
echo " krisyotam - Personal (gitea, codeberg, sourcehut, github, gitlab)"
echo " khr1st - Pentesting (github/imkhr1st, gitea)"
echo " laelyotam - Work (github only)"
echo ""
echo "Example: git-setup-mirrors krisyotam my-project"
exit 1
}
[ -z "$PROFILE" ] || [ -z "$REPO" ] && usage
# Verify we're in a git repo
git rev-parse --git-dir > /dev/null 2>&1 || {
echo "Error: Not in a git repository"
exit 1
}
echo "Setting up mirrors for '$REPO' with profile '$PROFILE'..."
case "$PROFILE" in
krisyotam)
# Primary remote (pull from github)
git remote set-url origin "git@github.com:krisyotam/${REPO}.git" 2>/dev/null || \
git remote add origin "git@github.com:krisyotam/${REPO}.git"
# Clear existing push URLs and add all mirrors
git remote set-url --push origin "git@git.krisyotam.com:krisyotam/${REPO}.git"
git remote set-url --add --push origin "git@codeberg.org:krisyotam/${REPO}.git"
git remote set-url --add --push origin "git@git.sr.ht:~krisyotam/${REPO}"
git remote set-url --add --push origin "git@github.com:krisyotam/${REPO}.git"
git remote set-url --add --push origin "git@gitlab.com:krisyotam/${REPO}.git"
echo "Mirrors configured:"
echo " - git.krisyotam.com:krisyotam/${REPO}"
echo " - codeberg.org:krisyotam/${REPO}"
echo " - git.sr.ht:~krisyotam/${REPO}"
echo " - github.com:krisyotam/${REPO}"
echo " - gitlab.com:krisyotam/${REPO}"
;;
khr1st)
# Primary remote (uses github-khr1st alias from ~/.ssh/config)
git remote set-url origin "git@github-khr1st:imkhr1st/${REPO}.git" 2>/dev/null || \
git remote add origin "git@github-khr1st:imkhr1st/${REPO}.git"
# Push mirrors
git remote set-url --push origin "git@github-khr1st:imkhr1st/${REPO}.git"
git remote set-url --add --push origin "git@git.krisyotam.com-khr1st:khr1st/${REPO}.git"
echo "Mirrors configured:"
echo " - github.com (imkhr1st) via github-khr1st alias"
echo " - git.krisyotam.com (khr1st) via ky-khr1st alias"
;;
laelyotam)
# Single remote (uses github-work alias from ~/.ssh/config)
git remote set-url origin "git@github-work:laelyotam/${REPO}.git" 2>/dev/null || \
git remote add origin "git@github-work:laelyotam/${REPO}.git"
echo "Remote configured:"
echo " - github.com (laelyotam) via github-work alias"
;;
*)
echo "Error: Unknown profile '$PROFILE'"
usage
;;
esac
echo ""
echo "Verify with: git remote -v"