Skip to content

Instantly share code, notes, and snippets.

@jaz303
Created October 21, 2013 19:02
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jaz303/7089132 to your computer and use it in GitHub Desktop.
Save jaz303/7089132 to your computer and use it in GitHub Desktop.
find all dirty git repos under the current working directory
#!/bin/bash
for dir in $(find . -name '.git' -type d)
do
dir=$(dirname $dir)
cd $dir
STATE=""
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
STATE="untracked-files ${STATE}"
fi
if ! git diff --quiet 2> /dev/null; then
STATE="modified ${STATE}"
fi
if ! git diff --cached --quiet 2> /dev/null; then
STATE="staged ${STATE}"
fi
if [[ -n $STATE ]]; then
echo "${dir}: ${STATE}"
fi
cd - > /dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment