Skip to content

Instantly share code, notes, and snippets.

@kulvind3r
Last active July 13, 2020 13:49
Show Gist options
  • Save kulvind3r/a405043c2a28e479f13a773d76f89770 to your computer and use it in GitHub Desktop.
Save kulvind3r/a405043c2a28e479f13a773d76f89770 to your computer and use it in GitHub Desktop.
Minimalist git multi script. Make alias 'gm' to script, use as "gm <git_command>" to run command across multiple checked out git repos.
#!/bin/bash
set -e
ARG="$1"
WORK_DIR=$(pwd)
run() {
for DIR in $(find $WORK_DIR/ -maxdepth 1 -type d)
do
cd "${DIR}"
[[ -d .git ]] && printf "\n\n==== %s ====\n\n" $(basename ${DIR}) && git $ARG
done
#Return to work directory
cd $WORK_DIR
}
run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment