summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2014-04-12 18:31:20 +0200
committerGravatar Tom Willemse2014-04-12 18:31:20 +0200
commitf5b218e0bec2d0ebbd0eae0c9cbdcefc878ebebd (patch)
tree0f2a51c112c4ef5492d7014f8f6f68d9ee2b5054
downloadpush-remotes-f5b218e0bec2d0ebbd0eae0c9cbdcefc878ebebd.tar.gz
push-remotes-f5b218e0bec2d0ebbd0eae0c9cbdcefc878ebebd.zip
Initial commit
-rwxr-xr-xpush-remotes22
1 files changed, 22 insertions, 0 deletions
diff --git a/push-remotes b/push-remotes
new file mode 100755
index 0000000..6720312
--- /dev/null
+++ b/push-remotes
@@ -0,0 +1,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