Git Developer Guide

How to find all Git repos with uncommitted changes on Mac

The Command Line Solution

To find every Git repository with uncommitted, modified, deleted, or untracked files from the terminal, you can combine find with git status --porcelain:

# Search inside ~/Projects
find ~/Projects -name .git -type d -prune | while read -r gitdir; do
  repo=$(dirname "$gitdir")
  if [ -n "$(git -C "$repo" status --porcelain 2>/dev/null)" ]; then
    echo "Dirty: $repo"
    git -C "$repo" status -s
  fi
done

Why this is slow on macOS

On macOS, process creation via posix_spawn or fork is relatively heavy compared to Linux. Running find and invoking a subprocess for every repository:

The easier way: GitMon

GitMon parses the binary .git/index stat cache directly in Swift. It identifies dirty files in single-digit milliseconds with zero background CPU usage.

Download GitMon Free Trial Learn more

Related Guides