home/bin/git-new-push-remote (view raw)
1#!/bin/sh
2# git new-push-remote: adds a new push-only remote to a repository
3# without removing the existing push remote.
4
5[[ "$@" == "" ]] && {
6 printf '%s\n' "usage: git new-push-remote <remote url>"
7 exit
8}
9
10old_push_remote="$(git remote -v | grep '(push)' | awk '{print $2}')"
11git remote set-url "$(git remote show)" --add --push "$1"
12git remote set-url "$(git remote show)" --add --push "$old_push_remote"