#!/bin/bash do_stash=0 STASH_MESSAGE_DEF="Sync repositories to branch" STASH_MESSAGE_USR="" # not implemented yet do_pull=0 REPOSITORIES=(\ "Projects/application" \ "Projects/common" \ "Projects/ui.scripts" \ "Projects/ui.config" \ "Projects/cloudsync" \ "Projects/drtserver" \ "Projects/dry-demo" \ "Projects/dialin" \ "Projects/simulator" \ ) BRANCH="staging" if [[ "$1" != "" ]]; then if [[ "$1" != *"--"* ]]; then BRANCH="$1" fi fi if [[ "$*" == *"--stash"* ]]; then do_stash=1 fi if [[ "$*" == *"--pull"* ]]; then do_pull=1 fi read -p "Checking out all the repositories to the '$BRANCH' branch:(y/n)" -n 1 -r echo if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1 fi for repo in ${REPOSITORIES[@]}; do echo echo " -------------------- $repo -------------------- " echo cd "$HOME/$repo" git status if (( $do_stash ));then if [[ $STASH_MESSAGE_USR == "" ]]; then git stash push -m "$STASH_MESSAGE_DEF $BRANCH" else git stash push -m "$STASH_MESSAGE_USR" fi fi git checkout $BRANCH if (( $do_pull ));then git pull; fi git branch | grep "*" git status done