Skip to content

Instantly share code, notes, and snippets.

@rlcamp
Last active November 3, 2023 17:03
Show Gist options
  • Save rlcamp/2b2e0e722c58473e45c7ad7e2b2d84a7 to your computer and use it in GitHub Desktop.
Save rlcamp/2b2e0e722c58473e45c7ad7e2b2d84a7 to your computer and use it in GitHub Desktop.
list git repos with uncommitted or unpushed changes
#!/bin/sh
set -e
for repo in $(find . -mindepth 2 -type d -name '.git' | sed -e 's/\/.git//'); do
(cd $repo &&
git diff --exit-code HEAD &&
git log --decorate --oneline | head -n1 | grep origin
) 1>/dev/null || printf '"%s" has uncommitted or unpushed changes\n' $(basename $repo) >&2
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment