17 lines
418 B
Bash
Executable File
17 lines
418 B
Bash
Executable File
#!/bin/sh
|
|
# set given repository as upstream or add as a new remote
|
|
# ARGS:
|
|
# - user/org
|
|
# - repo
|
|
# - remote name
|
|
if test "$3"
|
|
then
|
|
name="$3"
|
|
git remote remove "$3" 2>/dev/null
|
|
else
|
|
git remote get-url upstream >/dev/null 2>&1 && name="$1" || name="upstream"
|
|
fi
|
|
origin="$(git remote get-url origin)"
|
|
git remote add -f $name "$(echo $origin | cut -d':' -f1):$1/${2:-$(echo $origin | cut -d'/' -f2)}"
|
|
git remote -v
|