Both Numbers, One Real Command
git fetch origin
git rev-list --left-right --count master...origin/feature/old-refactor
The triple-dot range compares both directions at once: the first number is commits master has that the branch lacks, the second is commits the branch has that master lacks.
Seeing Exactly What's on Each Side
git log --oneline master..origin/feature/old-refactor
git log --oneline origin/feature/old-refactor..master
Real, specific commits, not just counts — genuinely useful for judging how bad the eventual merge or rebase will be.
Why This Is Worse Than One Number Alone
A branch that is only "6 commits behind" is a simple catch-up. A branch that is only "6 commits ahead" is a normal feature in progress. A branch that is genuinely BOTH means every one of its own real commits was written against a version of the shared files that no longer exists — the eventual merge has to reconcile real, independent changes on both sides at once, not just catch up one direction.
Somewhere in the real project history, feature/old-refactor was branched off, worked on for a while, and then genuinely forgotten. Master kept moving. The branch kept its own real commits too. Neither side knows about the other's recent work.
Before writing any judgment about what to do next, the real, measurable facts come first: exactly how far ahead, and exactly how far behind, has this branch actually drifted? git rev-list answers both numbers at once, in one real command.
git rev-list --left-right --count a...b
Reports two real numbers at once: commits reachable from a but not b, and commits reachable from b but not a. Confirmed directly in this lab producing "6\t6" — six commits master has that the branch lacks, six the branch has that master lacks.
Takeaways
- git rev-list --left-right --count a...b reports both directions of divergence in one real command
- A branch that is both ahead AND behind is genuinely worse than either alone — real, independent drift on both sides
- Vague commit messages ("WIP") compound the real cost of a long-lived branch, hiding what its own commits actually did
- The real fix is a team habit — regular rebasing or merging against main — not a one-time git command