2021-06-18 15:51:57 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# set given repository as upstream or add as a new remote
|
|
|
|
if test "$3"
|
|
|
|
then
|
2021-09-24 18:20:29 +00:00
|
|
|
name="$3"
|
2021-06-18 15:51:57 +00:00
|
|
|
git remote remove "$3" 2>/dev/null
|
|
|
|
else
|
2021-09-24 18:20:29 +00:00
|
|
|
git remote get-url upstream 2>/dev/null && name="$1" || name="upstream"
|
2021-06-18 15:51:57 +00:00
|
|
|
fi
|
2021-09-24 18:20:29 +00:00
|
|
|
origin="$(git remote get-url origin)"
|
2021-06-18 15:51:57 +00:00
|
|
|
git remote add -f $name "$(echo $origin | cut -d':' -f1):$1/${2:-$(echo $origin | cut -d'/' -f2)}"
|
|
|
|
git remote -v
|