Last active
January 27, 2026 04:00
-
-
Save mikelaaron/3bc6b7fecdb188fdce289fee4c51c515 to your computer and use it in GitHub Desktop.
Bash script to check git status across all repos in a folder at once. Shows uncommitted changes, untracked files, commits to push/pull, and sync status. Run gitstatus from anywhere.
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 | |
| # Git Status Overview for All Repos | |
| # | |
| # After saving this file, run these commands to set it up: | |
| # chmod +x /path/to/git-status-all.sh | |
| # echo 'alias gitstatus="/path/to/git-status-all.sh /your/projects/folder"' >> ~/.zshrc | |
| # source ~/.zshrc | |
| BOLD='\033[1m' RED='\033[0;31m' GREEN='\033[0;32m' | |
| YELLOW='\033[0;33m' BLUE='\033[0;34m' NC='\033[0m' | |
| echo -e "${BOLD}Git Repository Status${NC}" | |
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | |
| SCAN_DIR="${1:-.}" | |
| for dir in "$SCAN_DIR"/*/; do | |
| [ -d "$dir/.git" ] || continue | |
| repo_name=$(basename "$dir") | |
| cd "$dir" || continue | |
| branch=$(git branch --show-current 2>/dev/null) | |
| [ -z "$branch" ] && branch="(detached)" | |
| if ! git diff --quiet 2>/dev/null || ! git diff --cached --quiet 2>/dev/null; then | |
| has_changes=true | |
| else | |
| has_changes=false | |
| fi | |
| untracked=$(git ls-files --others --exclude-standard 2>/dev/null | wc -l | tr -d ' ') | |
| git fetch --quiet 2>/dev/null | |
| ahead=$(git rev-list --count @{upstream}..HEAD 2>/dev/null || echo "?") | |
| behind=$(git rev-list --count HEAD..@{upstream} 2>/dev/null || echo "?") | |
| status="" needs_attention=false | |
| [ "$has_changes" = true ] && status+="${RED}●${NC} uncommitted " && needs_attention=true | |
| [ "$untracked" -gt 0 ] && status+="${YELLOW}◐${NC} ${untracked} untracked " && needs_attention=true | |
| [ "$ahead" != "?" ] && [ "$ahead" -gt 0 ] && status+="${BLUE}↑${NC} ${ahead} to push " && needs_attention=true | |
| [ "$behind" != "?" ] && [ "$behind" -gt 0 ] && status+="${YELLOW}↓${NC} ${behind} to pull " && needs_attention=true | |
| [ "$ahead" = "?" ] && status+="${YELLOW}⚠${NC} no upstream " | |
| [ "$needs_attention" = false ] && [ "$ahead" != "?" ] && status="${GREEN}✓${NC} clean & synced" | |
| printf "${BOLD}%-25s${NC} [%s] %b\n" "$repo_name" "$branch" "$status" | |
| cd - > /dev/null || exit | |
| done | |
| echo -e "\nLegend: ${RED}●${NC}=changes ${YELLOW}◐${NC}=untracked ${BLUE}↑${NC}=push ${YELLOW}↓${NC}=pull ${GREEN}✓${NC}=synced" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment