File: git-rename-remote

package info (click to toggle)
git-extras 7.4.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 2,120 kB
  • sloc: sh: 4,312; python: 994; makefile: 146
file content (20 lines) | stat: -rwxr-xr-x 428 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/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