mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 15:36:21 -04:00
21 lines
428 B
Bash
Executable file
21 lines
428 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
old=$1
|
|
new=$2
|
|
|
|
test -z "$old" && echo "old remote name required." 1>&2 && exit 1
|
|
test -z "$new" && echo "new remote name required." 1>&2 && exit 1
|
|
|
|
if ! git config --get "remote.$old.fetch" > /dev/null; then
|
|
echo "remote $old doesn't exist"
|
|
exit 1
|
|
fi
|
|
|
|
if git config --get "remote.$new.fetch" > /dev/null; then
|
|
git remote remove "$new"
|
|
fi
|
|
git remote rename "$old $new"
|
|
git remote -v
|