Last active
December 17, 2025 14:15
-
-
Save allain/55dbe2ee5a406be2ea5aca1392380dfe to your computer and use it in GitHub Desktop.
Find Repose with uncommited changes recursively
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Find all git repositories recursively and print those with uncommitted changes | |
| # Find all .git directories | |
| find . -type d -name ".git" 2>/dev/null | while read -r git_dir; do | |
| # Get the repository root (parent of .git directory) | |
| repo_path=$(dirname "$git_dir") | |
| # Convert to absolute path | |
| abs_path=$(cd "$repo_path" 2>/dev/null && pwd) | |
| # Skip if we couldn't get the absolute path | |
| [ -z "$abs_path" ] && continue | |
| # Check if there are uncommitted changes using git -C to avoid changing directories | |
| if ! git -C "$abs_path" diff-index --quiet HEAD -- 2>/dev/null || [ -n "$(git -C "$abs_path" ls-files --others --exclude-standard 2>/dev/null)" ]; then | |
| echo "$abs_path" | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment