Skip to content

Instantly share code, notes, and snippets.

@vi7
Last active December 31, 2021 12:35
Show Gist options
  • Save vi7/0f8d9b733e5ebd4e5512448d665050bc to your computer and use it in GitHub Desktop.
Save vi7/0f8d9b733e5ebd4e5512448d665050bc to your computer and use it in GitHub Desktop.
Oneliner scripts to check Git working tree status for multiple repositories in a batch
#!/usr/bin/env bash
# Collection of oneliner scripts to check Git working tree status for multiple repositories in a batch
set -e
# The most simple, prints all the git repos found and outputs not commited changes if any
for dir in $(find . -type d -name '.git'); do pushd $dir/.. >/dev/null; pwd; git status --short; popd >/dev/null; done
# Print paths to repositories with uncommitted changes only
for dir in $(find . -type d -name '.git'); do pushd $dir/.. >/dev/null; if [ $(git status --short | wc -l) -ne 0 ]; then pwd; fi; popd >/dev/null; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment