Skip to content

Instantly share code, notes, and snippets.

@tanevanwifferen
Forked from jaz303/find_dirty_gits
Created February 26, 2020 22:33
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 tanevanwifferen/32dbeaba4d50d4a675c4cd45eb7cc689 to your computer and use it in GitHub Desktop.
Save tanevanwifferen/32dbeaba4d50d4a675c4cd45eb7cc689 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