3 # Syncs with remote hosts in the git (sub)directories.
5 # Allows fetching (no merge) and pushing at the moment.
8 # Select the method: fetch, push and status is possible.
9 if [ x$1 = x -o x$1 = xfetch -o x$1 = xfe ]; then
11 elif [ $1 = push -o $1 = pu ]; then
13 elif [ $1 = status -o $1 = st ]; then
16 echo "Usage: sync.sh [fetch | fe | push | pu | status | st]"
18 echo "fetch: Fetch from all remotes."
19 echo "push: Push to all remotes."
20 echo "status: Display status for all git repositories."
24 # Execute the given method for each git subdirectory.
25 for project in `find . -name .git -type d`; do
29 # Remove .git from repository name.
30 project=`echo "$project" | sed "s|.git||"`
32 # Display all commits not in the master branch.
33 if [ $method = status ]; then
34 output=`git log --graph --all --pretty=oneline --color master..`
35 if [ "x$output" != x ]; then
36 echo "$project status:"
39 # Fetch from/Push to all remotes.
41 for remote in `git remote`; do
42 echo "$project: ${method}ing $remote ..."
50 # Run status after a fetch to see new changes.
51 if [ $method = fetch ]; then