Interview Prep/Git & GitHub/Repository Health, Size and Performance

A PR job runs `git diff --name-only origin/main...HEAD` and fails with `fatal: origin/main...HEAD: no merge base`.

IntermediateTroubleshootingRepository Health, Size and Performance
Answer

Likely causes → The CI clone is shallow, so the common ancestor of main and the PR branch is not in the local history. Three-dot syntax needs that merge base.

Diagnose →

git rev-parse --is-shallow-repository
git log --oneline -3 origin/main; git log --oneline -3 HEAD

Fix → Fetch enough history for both sides, or everything:

git fetch --no-tags --depth=200 origin main
git fetch --deepen=200            # deepen the PR side too
# or simply: actions/checkout with fetch-depth: 0
git diff --name-only origin/main...HEAD

Prevent → For "changed files" logic use fetch-depth: 0, or a dedicated action/API (gh pr diff --name-only) instead of guessing a depth.

All Git & GitHub questions Roadmap: Git & GitHub

More on Repository Health, Size and Performance