Created
October 7, 2024 21:14
-
-
Save 7enderhead/beb9c24edbb6d5b4b5f92f8a327e49b1 to your computer and use it in GitHub Desktop.
Check Subfolders for Git Status
This file contains 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
#!/usr/bin/env bash | |
# Function to check git status | |
check_git_status() { | |
local dir="$1" | |
cd "$dir" || return | |
# Check if it's a git repository | |
if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1; then | |
# Get git status | |
local status=$(git status --porcelain) | |
# If there are changes, print the directory name and status | |
if [ -n "$status" ]; then | |
echo "Changes in $dir:" | |
echo "$status" | |
echo | |
fi | |
fi | |
cd - > /dev/null | |
} | |
# Main script | |
for dir in */; do | |
if [ -d "$dir" ]; then | |
check_git_status "$dir" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment