gitshell/upstream
alemi 6bdae48354 feat: pushing existing commands
i made this some time ago, pushing as one commit
2024-01-12 09:46:11 +01:00

26 lines
655 B
Bash
Executable file

#!/bin/bash
if [ $# -lt 2 ]; then
echo "[!] must specify both repository and remote"
exit
fi
REPOSITORY="$1"
URL="$2"
if [[ ! "$REPOSITORY" == *.git ]]; then
REPOSITORY="$REPOSITORY.git"
fi
if [ ! -d "/srv/git/$REPOSITORY" ]; then
echo "[!] repository does not exist"
exit
fi
REMOTE="origin" # TODO can we get this as argument but optionally?
cd "/srv/git/$REPOSITORY"
git remote remove "$REMOTE" # TODO this complains about branches abandoned, but we will recreate the remote right after this, so maybe do it smartly and check?
git remote add "$REMOTE" "$URL"
git config remote.$REMOTE.mirror "true"
git config remote.$REMOTE.direction "up"