Get a list of changed files and their status for a specific Git commit
Use --name-status
instead of --name-only
git diff-tree --no-commit-id --name-status -r <SHA>
This will show the filename with a status letter of (extracted from man): Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their type (i.e. regular file, symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown (X), or have had their pairing Broken (B).
While Joe's answer points out that you can use the --name-status
flag with git diff-tree
, you can also use the same flag with git diff
instead.
To get the changed files with their status for just a specific commit, you can just use the sha id of that commit with a commit-parent specifier, like so
git diff --name-status <sha>^ <sha>
The revision specifier <sha>^
means the first parent of the commit <sha>
, so using that with git diff
effectively gives you all the changes that were made between a commit and its parent.
Alternative
You can also use
git diff --name-status <sha>~ <sha>
where <sha>~
also means the first parent of commit <sha>
.