Created
September 20, 2025 17:31
-
-
Save jimdiroffii/8f2c55c63824147a1a2fdce6676d19fd to your computer and use it in GitHub Desktop.
Check status of all repos
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 | |
| # The directory containing your git repositories, passed as the first argument. | |
| PARENT_DIR="$1" | |
| # Check if a directory was provided. | |
| if [ -z "$PARENT_DIR" ]; then | |
| echo "β Error: No directory supplied." | |
| echo "Usage: $0 <path/to/your/repos>" | |
| exit 1 | |
| fi | |
| # Check if the provided path is actually a directory. | |
| if [ ! -d "$PARENT_DIR" ]; then | |
| echo "β Error: '$PARENT_DIR' is not a valid directory." | |
| exit 1 | |
| fi | |
| # Loop through each item in the parent directory. | |
| for dir in "$PARENT_DIR"/*; do | |
| # Check if the item is a directory AND it contains a .git folder. | |
| if [ -d "$dir/.git" ]; then | |
| echo "-----------------------------------------------------" | |
| # Use basename to get just the folder name from the path. | |
| echo "π Status for: $(basename "$dir")" | |
| echo "-----------------------------------------------------" | |
| # Run 'git status' inside a subshell. | |
| # The 'cd' is temporary and won't affect the script's main working directory. | |
| (cd "$dir" && git status) | |
| echo "" # Add a blank line for readability. | |
| fi | |
| done | |
| echo "β All repositories checked." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment