dotfiles/.local/bin/scripts/git-fork

18 lines
549 B
Bash
Executable File

#!/bin/sh -e
# Clones a fork and sets a corresponding upstream
# ARGS
# - repo name (omit if setting upstream in existing repo)
# - upstream user
# - local user
# - url
# - target directory name (and further arguments to clone)
if test -d ".git"
then repo="$(basename "$PWD")"
git remote set-url origin "$(git-repo "${3:-github.com}" "$repo" "$2" "${@:4}")"
else repo="$1"
git-get "${3:-github.com}" "$repo" "$2" "${@:4}"
cd $(expr "$5" \| "$1")
fi
test "$1" && git remote add upstream "$(git-repo "${3:-github.com}" "$repo" "$1")"
git remote -v