Skip to content

Instantly share code, notes, and snippets.

@justincy
Created December 16, 2015 22:55
Show Gist options
  • Save justincy/67f7e505296a4b4cd478 to your computer and use it in GitHub Desktop.
Save justincy/67f7e505296a4b4cd478 to your computer and use it in GitHub Desktop.
Iterate over all sub directories and print a list of which git repos have uncommitted changes.
#!/bin/bash
# Loop through all files and directories
for dir in ./*
do
# Skip files
if [ -d $dir ]; then
cd $dir;
# Filter down to only git repos
if [ -d ".git" ]; then
# Print repos that have uncommitted changes
# http://stackoverflow.com/a/9393642
if [[ -n $(git status -s) ]]; then
echo $dir;
fi;
fi;
cd ..;
fi;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment