List files changed between two Git revisions
Use name-only, name-status, or statistics output, distinguish endpoint and merge-base comparisons, and handle paths safely in scripts.
Use git diff --name-only A B to list paths that differ between two snapshots. Use --name-status to include change types, or --stat for a per-file summary. Replace A and B with commits, branches, or tags that identify the intended endpoints.
Choose the comparison
git diff --name-only v1.0.0 v1.1.0
git diff --name-only main develop
git diff --name-only HEAD~10 HEAD
The last command compares HEAD with its tenth first-parent ancestor. It does not mean “show every file touched in exactly ten commits” when merges or changes later undone are involved. Endpoint diffs report the net tree difference.
git diff --name-status A B
git diff --stat A B
git diff --shortstat A B
git diff --name-only A B -- src/
Status letters include A for added, M for modified, D for deleted, and R for a detected rename. Rename detection is based on content similarity and configuration; a rename is not stored as a special historical operation.
Filter a release checklist
git diff --name-only v1.4.0 v1.5.0 -- '*.sql' '*.yaml'
git diff --name-only --diff-filter=A A B
git diff --name-only --diff-filter=D A B
Quote patterns so Git receives them. Text statistics may show line counts, while binary changes have different summaries.
For scripts, use NUL-delimited output:
git diff --name-only -z --diff-filter=ACMR A B
The consumer must understand NUL separators. Without -z, unusual filenames can be quoted or escaped, and embedded newlines make line-based processing unsafe.
A path list does not contain the B-version file content and does not guarantee that the path exists in your current checkout. Do not pipe it directly into an archive command and call the result a versioned change package. A git diff --binary A B patch can carry applicable content changes; git archive B exports a snapshot. Submodules and external artifacts require their own handling.
Two dots and three dots
For git diff, A B and A..B both compare the endpoint trees. A...B compares a merge base of A and B with B, which is often useful for reviewing a feature branch. It is directional and is not the symmetric commit-set meaning used by git log A...B. Unusual histories with multiple merge bases deserve explicit inspection.
Uncommitted changes and path roots
git diff --name-only compares the working tree with the index. Add --cached to compare the index with HEAD. Neither normally includes untracked files; use git status --short to see those too.
By default, paths are relative to the repository root. --relative can restrict and rewrite paths for a subdirectory; configuration such as diff.relative can affect the default. Use a known repository root and explicit options when feeding another tool.
See git-diff and git-archive.
Contact us
Join the community
to join the community
Try Guance
Start online and pay only for what you use.
Get startedChoose a Guance plan