Skip to content

Instantly share code, notes, and snippets.

@jimdiroffii
Created September 20, 2025 17:31
Show Gist options
  • Select an option

  • Save jimdiroffii/8f2c55c63824147a1a2fdce6676d19fd to your computer and use it in GitHub Desktop.

Select an option

Save jimdiroffii/8f2c55c63824147a1a2fdce6676d19fd to your computer and use it in GitHub Desktop.
Check status of all repos
#!/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