Git Developer Guide

How to check unpushed commits across all Git repos on macOS

The Command Line Solution

To check if a single Git repository has unpushed commits on its current branch, Git provides the upstream revision range syntax:

# Count commits ahead of upstream
git rev-list --count @{u}..HEAD 2>/dev/null

# Or view the short status line
git status -sb

To loop through all developer directories from the terminal, developers typically run a shell script:

for d in ~/Projects/*/; do
  if [ -d "$d/.git" ]; then
    ahead=$(git -C "$d" rev-list --count @{u}..HEAD 2>/dev/null || echo 0)
    if [ "$ahead" -gt 0 ]; then
      echo "$(basename "$d"): $ahead unpushed commit(s)"
    fi
  fi
done

Where the CLI script falls short

While this script works for simple setups, it suffers from several real-world limitations:

The easier way: GitMon

GitMon lives in your macOS menu bar and automatically parses your repositories' Git metadata in milliseconds without launching subprocesses.

Download GitMon Free Trial Learn more

Related Guides