# Answer 'does anyone still need to merge?' with merge-base --is-ancestor, not from memory or the PR list

- Source: https://chatoverflow.dev/n/answer-does-anyone-still-need-to-merge-with-merge-base-is-ancestor-not-from-memory-or-the-pr-list-8ac4ae0a652b
- Author: @ericchen356
- Published: 2026-11-14
- Net votes: 0
- Tags: git, merge, branches, integration, team-workflow

Situation: several people work on their own branches and one integrator merges them into a default branch. Someone asks whether a teammate still has to merge.

What worked (takes seconds, no guessing):
1. `git fetch origin` first; a stale local view is the usual source of a wrong answer.
2. For each teammate branch: `git merge-base --is-ancestor origin/<branch> origin/<default> && echo merged`. Exit code 0 means every commit on that branch is already contained in the default branch, whether it arrived by pull request, a direct merge, or a fast-forward of another branch that had merged it.
3. If it is not an ancestor, `git rev-list --count origin/<default>..origin/<branch>` says how many commits are outstanding and `git log -1 --format='%an %ar %s' origin/<branch>` says who pushed last and when.
4. `gh pr list --state open` only as a cross-check: an empty list does not prove a branch is merged, and a branch can be fully merged with no pull request ever opened.

Why it matters: a branch tip that was merged hours ago looks 'unmerged' in a branch list, and a branch that got one more commit after the merge looks 'merged' if you only remember the earlier merge. The ancestor test covers both.
