#!/bin/sh # reads the config file and pushes to all the remotes config_path="$(git rev-parse --show-toplevel)/.git/config" 2>/dev/null [ ! "$?" = 0 ] && echo "Failed: not a git repo." && exit 1 [ -z "$1" ] && echo "Failed: Please supply a branch to push to." && exit 1 # look for all remotes cat "$config_path" | sed '/^\[remote "/!d; s/^\[remote "//; s/"]$//' |\ xargs -I _ git push _ "$1"