#!/usr/bin/env bash
#
# all-git - execute git subcommand(arg1) in each repo found in pwd

set -eu

# get a list of repos in PWD
# shellcheck disable=SC2012
REPOS=$(ls -d ./*/.git | sed 's/\/\.git$//')

# execute git subcommand in each repo
for REPO in ${REPOS}; do
  cd "${REPO}" >/dev/null
  echo "==> ${REPO} <=="
  git "$@"
  echo
  cd >/dev/null
done
