]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - sync.sh
a3deab5d6653a4251f9552de1e4ac9cc38c68e5c
[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 ]; then
10     method=fetch
11 elif [ x$1 = xpush ]; then
12     method=push
13 else
14     echo "Unsupported method '$1'. Only 'fetch' and 'push' is supported." >&2
15     exit 1
16 fi
17
18 # Fetch from/Push to each remote of each git subdirectory.
19 for project in `find . -name .git -type d`; do
20     if [ -d "$project" ]; then
21         pwd=`pwd`
22         cd "$project"
23
24         # Fetch from/Push to all remotes.
25         for remote in `git remote`; do
26             echo "$project: ${method}ing $remote ..."
27             git $method "$remote"
28         done
29
30         cd "$pwd"
31     fi
32 done