Skip to content

Instantly share code, notes, and snippets.

@paulera
Last active November 16, 2020 11:26
Show Gist options
  • Save paulera/893ba129ea7629fb8c3cd33970df40a7 to your computer and use it in GitHub Desktop.
Save paulera/893ba129ea7629fb8c3cd33970df40a7 to your computer and use it in GitHub Desktop.
Run a git command in all folders (same level, not recursive) that are a git repo.
#!/bin/bash
#
# Usage: gitall status
# gitall fetch
# gitall checkout master
# gitall ...git parameters...
#
if [[ "$OSTYPE" =~ "darwin" ]]; then
# MAC
ESC="\x1B"
else
ESC="\e"
fi
echo -n -e "\nCOMMAND: "
echo -e "$ESC[01;33m$(basename $0) $*$ESC[0m\n"
for i in *; do
if [ -d "$i/.git" ]; then
echo -e "$ESC[01;36m-----> "$i"$ESC[0m"
echo
cd $i
git $*
cd ..
echo
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment