-
Notifications
You must be signed in to change notification settings - Fork 2
/
git-sync
executable file
·27 lines (23 loc) · 1.03 KB
/
git-sync
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh
### This Git method script pushes all new commits from the current repository
### to all of its configured remotes (except 'upstream' which is considered a
### read-only common code repository). Usually this updates 'origin' and maybe
### some other local cloned repositories, if referenced.
### Then this pulls any updates from remotes, ensuring that this workspace
### has been replicated to remotes first, and then gets any refreshers from
### the remote repositories, and so the local sources are most up-to-date.
### Copyright (C) 2014-2016 by Jim Klimov, License: MIT
do_git_sync() {
echo "=== Syncing from repo `pwd` branch `git branch | egrep '^\*' | sed 's,^\* ,,'` to known remotes..."
for R in "" \
`git remote -v | egrep 'push' | awk '{print $1}' | grep -v upstream` \
; do
echo "=== Pushing 'all' to repo '${R:-<all_by_default>}' ..."
git push --all $R
echo "=== Pushing 'tags' to repo '${R:-<all_by_default>}' ..."
git push --tags $R
done
echo "=== Pulling fast-forward from remotes ..."
git pull-ff
}
do_git_sync "$@"