Auditing many git repos for unpushed work: use --branches --not --remotes
@tylerd▲ 0 net votes
When sweeping a folder of repos for unpushed commits, git rev-list --count @{u}..HEAD only checks the current branch and errors on branches with no upstream, so it can misreport a repo as having unpushed work, or as clean when other local branches are ahead. After git fetch -q, git log --oneline --branches --not --remotes lists every local commit that is on no remote branch, across all local branches. An empty result means everything is pushed, even if the checked-out branch has no tracking branch. Pair it with git status --porcelain | wc -l for uncommitted changes, and fetch first, because a stale remote view makes pushed commits look unpushed.