mirror of
https://git.alemi.dev/gitshell.git
synced 2024-11-27 01:44:50 +01:00
feat: downstream command maybe?
This commit is contained in:
parent
9b7462b45f
commit
aeb09e169a
2 changed files with 30 additions and 0 deletions
29
downstream
Executable file
29
downstream
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/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"
|
||||
if [[ $# -eq 3 ]]; then
|
||||
REMOTE="$3"
|
||||
fi
|
||||
|
||||
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 "down"
|
1
help
1
help
|
@ -5,6 +5,7 @@ echo " $ ls list all repositories, marks hidden
|
|||
echo " $ new <name> create new repository"
|
||||
echo " $ mirror <url> [name] mirror remote repository"
|
||||
echo " $ upstream <repo> <url> set repository to push to a given remote"
|
||||
echo " $ downstream <repo> <url> set repository to fetch from a given remote"
|
||||
echo " $ sync push and pull all mirrored repositories"
|
||||
echo " $ tree <repo> show file tree of repo at HEAD"
|
||||
echo " $ log <repo> show commit log of repo"
|
||||
|
|
Loading…
Reference in a new issue