]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - sync.sh
Fix doc typo in sync.sh.
[config/dotfiles.git] / sync.sh
1 #!/bin/sh
2
3 # Syncs with remote hosts in the git (sub)directories.
4 #
5 # Allows fetching (no merge) and pushing at the moment.
6
7
8 # Select the method, fetch and push is possible.
9 if [ x$1 = x -o x$1 = xfetch -o x$1 = xfe ]; then
10     method=fetch
11 elif [ $1 = push -o $1 = pu ]; then
12     method=push
13 else
14     echo "Usage: sync.sh [fetch | fe | push | pu ]"
15     echo
16     echo "fetch: Fetch from all remotes."
17     echo "push: Push to all remotes."
18     exit 1
19 fi
20
21 # Fetch from/Push to each remote of each git subdirectory.
22 for project in `find . -name .git -type d`; do
23     if [ -d "$project" ]; then
24         pwd=`pwd`
25         cd "$project"
26
27         # Fetch from/Push to all remotes.
28         for remote in `git remote`; do
29             echo "$project: ${method}ing $remote ..."
30             git $method "$remote"
31         done
32
33         cd "$pwd"
34     fi
35 done