summaryrefslogtreecommitdiffstats
path: root/push-remotes
blob: 6720312928fc0ef70c16cea734dda6fef2d7bb6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
## push-remotes -- Push the given git directory to all of its remotes

## Commentary:

# This command expects the first argument to be a directory usable by
# the `--git-dir' command-line option to git. Afterwards it loops
# through all known remotes of that directory and pushes to it.

## Code:

function _git() { git --git-dir="$gitdir" "$@"; }

gitdir="$1"
remotes=$(_git remote)

if [[ -n "$remotes" ]]; then
    for remote in $remotes; do
        echo "Pushing master to ${remote}"
        _git push "$remote"
    done
fi