Skip to content

Instantly share code, notes, and snippets.

@bjconlan
Last active September 13, 2018 06:08
Show Gist options
  • Save bjconlan/66afbe2f9532fbf2bf9555b0a0427523 to your computer and use it in GitHub Desktop.
Save bjconlan/66afbe2f9532fbf2bf9555b0a0427523 to your computer and use it in GitHub Desktop.
Simple util function for working with multiple git repositories using the same parent folder
#!/usr/bin/env bash
# To have this work on windows (without extension) nicely its easiest
# just to create a bat file which calls `@echo off & bash -c "gf.sh %*"`
REPOS=*/
if [[ -r .gf ]]; then
REPOS=(`cat .gf`)
fi
for REPO in $REPOS; do
if [[ -d $REPO ]] && [[ -d $REPO/.git ]]; then
echo -e "\e[7m$REPO\e[27m"
git -C $REPO "$@"
else
echo "Unable to perform git command on directory $REPO"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment