Skip to content

Instantly share code, notes, and snippets.

@faloi
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save faloi/bbc27a4a5e40828e94be to your computer and use it in GitHub Desktop.
Save faloi/bbc27a4a5e40828e94be to your computer and use it in GitHub Desktop.
Scans all Git repositories at the given path and outputs those who have uncommited changes
#!/bin/bash
# Update all git directories below current directory or specified directory, asking for confirmation
function ask_yes_or_no() {
read -p "$1 ([y]es or [N]o): "
case $(echo $REPLY | tr '[A-Z]' '[a-z]') in
y|yes) echo "yes" ;;
*) echo "no" ;;
esac
}
HIGHLIGHT="\e[01;34m"
NORMAL='\e[00m'
DIR=.
if [ "$1" != "" ]; then DIR=$1; fi
cd $DIR>/dev/null; echo -e "${HIGHLIGHT}Scanning ${PWD}${NORMAL}";
for d in `find . -name .git -type d -prune`; do
cd $d/.. > /dev/null
status=$(git status -s)
echo -e "\n${HIGHLIGHT}`pwd`$NORMAL"
if [[ $(ask_yes_or_no "Push?") != "no" ]]; then
git push
fi
cd - > /dev/null
done
#!/bin/bash
# Scans all Git repositories at the given path and outputs those who have uncommited changes
HIGHLIGHT="\e[01;34m"
NORMAL='\e[00m'
DIR=.
if [ "$1" != "" ]; then DIR=$1; fi
cd $DIR>/dev/null; echo -e "${HIGHLIGHT}Scanning ${PWD}${NORMAL}";
for d in `find . -name .git -type d -prune`; do
cd $d/.. > /dev/null
status=$(git status -s)
if [[ -n $status ]]; then
echo -e "\n${HIGHLIGHT}`pwd`$NORMAL"
echo "$status"
fi
cd - > /dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment