#!/bin/bash # Shell Script for super-respositores that executes git on all sub-repositories # Homepage at http://www.bitweaver.org/wiki/supergit # Licensed under the GPL # Authors: github.com/spiderr function usage { appName=`basename $0` echo "Welcome to $appName. It acts on all directories in your project as if they were sub-respositories. For most commands, you simply type what you would normally for git, however you simply type $appName with desired parameters in the super-repository root of your project. For example:" echo "-- To clone, type '$appName git@github.com:bitweaver/bitweaver.git -b DEV testbw' which will clone, then intiliaze + update submodules and checkout the master branch for each submodule" echo "-- To commit, in the super repo root, type '$appName commit -a'" echo "-- To push, in the super repo root, type '$appName push origin'" } function git_exec_subs { echo "executing on all subrepositories: git $@" TOP_DIR="`pwd`"; for repo in `find "$TOP_DIR" -maxdepth 1 -mindepth 1 -type d -not -name .git` ; do echo "#### $repo - git $@" cd "$repo" git $@ done } case "$1" in "clone") eval moduleName=\$$# moduleName=`basename $moduleName` cloneParams=$@ if [ -z $moduleName ]; then moduleName='source'; cloneParams="$cloneParams $moduleName" fi TOP_DIR="`pwd`/$moduleName"; echo $TOP_DIR echo $1 to $moduleName; git $cloneParams cd $TOP_DIR git submodule init git submodule update for repo in `find "$TOP_DIR" -maxdepth 1 -mindepth 1 -type d -not -name .git` ; do cd "$repo"; git submodule init git submodule update git checkout master done ;; "") usage; ;; *) git_exec_subs $@; ;; esac