13 lines
392 B
Bash
Executable File
13 lines
392 B
Bash
Executable File
#!/bin/sh
|
|
# set given repository as upstream or add as a new remote
|
|
if test "$3"
|
|
then
|
|
local name="$3"
|
|
git remote remove "$3" 2>/dev/null
|
|
else
|
|
git remote get-url upstream 2>/dev/null && local name="$1" || local name="upstream"
|
|
fi
|
|
local 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
|