THE GITHTML FIELD GUIDE

Why a GitHub pull request shows unexpected changed files

GitHub pull requests use a three-dot comparison focused on changes from the common ancestor to the head branch. Unexpected files can therefore come from the selected base, extra head commits, or history changes rather than a broken viewer. Verify both repositories and branches, inspect the commit list, and compare the same revisions locally before modifying history.

Reproduce the comparison being shown

A local diff between the current base tip and head tip is not the same as a pull request’s merge-base-oriented view. If the base has advanced independently, the two views can legitimately show different patches. The request is highlighting what the head introduces relative to shared ancestry, not simply subtracting one current folder from another.

First check whether the base is the intended target. A feature branched from another unfinished feature can include that earlier work when proposed directly to main. Changing the base may be appropriate for a stacked contribution, but it should reflect the intended integration order, not merely hide inconvenient files from review.

Compare matching references locally

Fetch the relevant base and head through their verified remotes, then use the same endpoint identities. The example assumes local references already exist. Inspect both the three-dot patch and the head-only commit range. A tip-to-tip comparison is useful as a different diagnostic, provided you label it correctly.

  1. If unexpected changes come from extra commits on the head branch, preserve the work and prepare a coherent contribution rather than deleting files from the final snapshot at random.
  2. If a squash or rebase changed ancestry, inspect whether equivalent content exists under different commits; identical text does not imply identical history.
shell
git log --oneline base..head
git diff --stat base...head
git diff --stat base head
git log --graph --oneline --decorate -20 head

Update the proposal without erasing context

Once the cause is understood, choose the project’s accepted correction: an appropriate base change, a focused new branch, or a coordinated history adjustment. Recheck the entire Files changed list afterward and tell reviewers why the comparison changed. Earlier comments may no longer cover the revised scope.

Do not assume a large diff is harmless because the final application appears to work. It may expose unrelated files or make the proposal impossible to review accurately. Conversely, do not force a smaller diff by discarding meaningful history without understanding the dependency. The goal is a comparison that accurately expresses the intended contribution and a clear explanation of any remaining stacked or prerequisite work.

  1. If the surprising file comes from a prerequisite feature, locate the commit that introduced it and check whether that prerequisite is already merged in the intended form. A squash-merged prerequisite can leave different ancestry. Compare the actual content and integration order before deciding how to restack the proposal.
  2. When local and hosted file counts disagree, record the resolved base and head identifiers used in each comparison. A fresh local fetch and an older browser view can describe different moments. Reproduce the same endpoints first, then investigate merge-base behavior if the discrepancy remains.

Sources and further reading

AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.

All github documentation workflows guides →

Read as MarkdownAll guides

Why a GitHub pull request shows unexpected changed files · gitHtml