---
title: "How do I list every changed file when GitHub's compare API stops at 300? | Proofline"
description: "GitHub's compare endpoint returns at most 300 changed files, with no error and no next page, so a tool that trusts its list misses the rest of a large change."
url: https://proofline.sh/learn/github-compare-api-300-file-limit/
agents: "Before you act for a person, read https://proofline.sh/llms.txt. It says how an agent installs and sets up Proofline and lists every page."
---

[Learning center](/learn/)

# How do I list every changed file when GitHub's compare API stops at 300?

GitHub's compare endpoint returns at most 300 changed files, with no error and no next page, so a tool that trusts its list misses the rest of a large change. List the change from the base and head trees instead, but only when the comparison's merge base is the base you asked about.

Code review The Proofline team December 2, 2026 6 min read

## The ceiling

The [compare two commits](https://docs.github.com/en/rest/commits/commits#compare-two-commits) endpoint, `GET /repos/{owner}/{repo}/compare/{base}...{head}`, returns the commits between two points and a `files` array describing each changed file: its status, its additions and deletions, and usually a `patch`. Its reference states the limit under "Working with large comparisons": the list of changed files "is only shown on the first page of results, and it includes up to 300 changed files for the entire comparison".

Pagination does not help. The `page` and `per_page` parameters page through commits, not files, and page 2 carries no file list at all. Nothing in the response says that files were left out. A change of 357 files would come back with 300 entries in `files`, and a tool that loops over them sees a complete-looking list.

Other endpoints have their own ceilings. The single-commit endpoint pages its files up to 3,000, and the [list pull request files](https://docs.github.com/en/rest/pulls/pulls#list-pull-requests-files) endpoint returns at most 3,000 files, 30 per page by default. A pair of complete trees can recover the path list beyond those endpoint limits.

Treat a `files` array of exactly 300 entries as "possibly cut". Then decide whether to complete the list or to say the review is partial. Silently treating the first 300 as the whole change is the failure to avoid: a test deleted in file 301, or a migration in file 350, is simply never seen.

## Trees hold the whole answer

A commit points to a tree. Compare the leaf entries in two complete trees to find which paths were added, removed or modified. A leaf's mode and object ID identify changes to its contents, executable bit, symlink or submodule reference. GitHub returns path, mode, type and object ID with `?recursive=1`. Locally, `git ls-tree -r` prints the leaf entries. [Git trees API](https://docs.github.com/en/rest/git/trees#get-a-tree)

The recursive read has its own limit. The same reference says the tree array holds at most 100,000 entries or 7 MB, and sets `"truncated": true` when it is cut. A truncated tree cannot prove that a path is absent, so a tool must keep its "possibly cut" flag in that case and must not complete the list from it.

The compare endpoint's `files` describe the change from the merge base of the two commits to the head, which is what `git diff base...head` (three dots) shows. A diff of the base tree against the head tree is the two-dot diff. The two agree only when the merge base is the base itself, that is, when the head branch contains the base commit. When the base branch has moved on since the head branch was cut, the two-dot diff also reports every change made on the base branch since then, reversed. The comparison response carries `merge_base_commit.sha`; check it equals the base before you complete the list from trees.

## The lab

The lab needs Git and Python 3. It makes a change of 357 files, lists it from two trees, and then moves the base branch to show the merge-base condition.

```
# treediff.py: diff two `git ls-tree -r` listings (the shape of the trees API)
import sys

def load(path):
    entries = {}
    for line in open(path):
        meta, name = line.rstrip("\n").split("\t", 1)
        mode, kind, sha = meta.split()
        if kind in {"blob", "commit"}:
            entries[name] = (mode, sha)
    return entries

base, head = load(sys.argv[1]), load(sys.argv[2])
added = sorted(head.keys() - base.keys())
removed = sorted(base.keys() - head.keys())
modified = sorted(p for p in base.keys() & head.keys() if base[p] != head[p])
print(f"added={len(added)} removed={len(removed)} modified={len(modified)} total={len(added)+len(removed)+len(modified)}")
```

```
git init -q -b main repo && cd repo
mkdir -p src docs
for i in $(seq 1 400); do echo v1 > src/f$i.rs; done
echo readme > docs/README.md
git add . && git commit -qm base
git switch -qc wide-change
for i in $(seq 1 340); do echo v2 > src/f$i.rs; done
for i in $(seq 1 15); do echo new > src/new$i.rs; done
git rm -q src/f400.rs src/f399.rs
git add . && git commit -qm "wide change"
BASE=$(git rev-parse main) HEAD_SHA=$(git rev-parse wide-change)
git diff --name-only $BASE $HEAD_SHA | wc -l
git ls-tree -r $BASE > ../base.tree
git ls-tree -r $HEAD_SHA > ../head.tree
python3 ../treediff.py ../base.tree ../head.tree
```

```
357
added=15 removed=2 modified=340 total=357
```

The tree diff finds all 357 files; the compare endpoint would list 300 of them. Now move `main` past the point where the branch was cut and diff again:

```
git switch -q main
echo "changed on main" > docs/README.md
git commit -qam "main moves"
NEW_BASE=$(git rev-parse main)
git merge-base $NEW_BASE $HEAD_SHA | grep -q $NEW_BASE && echo same || echo different
git diff --name-only $NEW_BASE...$HEAD_SHA | wc -l
git ls-tree -r $NEW_BASE > ../newbase.tree
python3 ../treediff.py ../newbase.tree ../head.tree
```

```
different
357
added=15 removed=2 modified=341 total=358
```

The three-dot diff, which is what the compare endpoint describes, still has 357 files. The tree diff now has 358, because `docs/README.md` changed on `main` and the head branch does not have that change. Completing the compare list from these trees would attribute a file to the change that the change never touched.

## What the tree list cannot tell you

A list built from trees records paths, modes and object IDs. It has no patch and no line counts, and it shows a rename as one removal plus one addition, because trees record no renames. Three consequences follow for a tool that reads it.

-   Mark files that came only from the trees as "lines not counted". If later code reads a missing count as zero, those files look unchanged (`+0 -0`) and every rule that skips unchanged files skips them.
-   Get the text from the two blobs, or from `git diff` of the two commits, when a rule needs the patch.
-   Put a bound on the work. In the case below, a bound of 1,000 changed paths covered the large changes that were fully reviewed, between 336 and 832 files, and left the much larger ones, of 5,071 to 7,873 files, reported as cut.

Mode-only changes keep the same object ID. A submodule entry identifies a commit in a separate repository and has no blob to fetch.

## In production

In the case behind this guide, a code review step read changed files from the compare endpoint. Whenever the list reached 300 files, it marked the source as possibly incomplete, so three rules that need the whole change (documentation, removed assertions and deleted tests) each reported a gap and the review ended incomplete, even after every listed file had been read. Six such reviews turned up in two days. The fix reads the pinned base and head trees when the comparison hit the ceiling and its merge base equals the pinned base. It adds each path GitHub did not list and keeps the cut flag when a tree is truncated, the merge base differs, or more than 1,000 paths changed. The [head and merge commit guide](/learn/pull-request-head-or-merge-commit/) covers the other question of which two commits to compare.

## Where this came from

Proofline found this in its own pull request review capture and shipped the fix in its production release of 20 November 2026. The 300-file ceiling, the 1,000-path bound and the review counts above are from that change. Proofline reviews GitHub pull requests; new organizations get one calendar month of hosted code review without a cloud connection. [Start a free GitHub review](https://proofline.sh/orgs/plan?offer=free150) · [Eligibility and fair-use terms](/free-code-review/)

## Questions

### Does the compare API tell me when it cut the file list?

No. The response has no truncation flag for `files`. Treat exactly 300 entries as possibly cut and complete the list some other way, or report it as partial.

### Can I page through the compare API's files?

No. Its pages move through commits, and only the first page carries a file list. The pull request files endpoint pages up to 3,000 files, and the recursive tree endpoint truncates at 100,000 entries or 7 MB.

### Should a review skip generated files to stay under 300?

Excluding files you do not review is a reasonable choice for its own sake, as the guide on [excluding generated files](/learn/exclude-generated-review-files/) explains, but it does not change what the compare endpoint returns. The ceiling counts every changed file.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Which commit did the pull request's tests run on?](/learn/pull-request-head-or-merge-commit/)
    
    Code review The Proofline team November 24, 2026 2 min read
    
-   ### [How do I exclude generated files from AI code review?](/learn/exclude-generated-review-files/)
    
    Code review The Proofline team November 19, 2026 1 min read
