Get a list of changed files and their status for a specific Git commit
Solution 1
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).
Solution 2
Use
git whatchanged
to see the last commit
Solution 3
Thanks to hvd's comment on stdcall's answer,
Your original answer, which included the
git whatchanged SHA-1
form, was almost right: add the-1
option to get only that specific commit.
here is the solution for those who are interested:
git whatchanged <SHA> -1
Another solution is:
git diff-tree --no-commit-id -r <SHA>
Solution 4
git checkout <commit>
git whatchanged -1
Ashraf Bashir
Senior Full Stack Software Developer, and Tech Team Lead in Booking.com
Updated on July 29, 2020Comments
-
Ashraf Bashir almost 4 years
I use the following Git command
git diff-tree --no-commit-id --name-only -r <SHA>
to get a list of changed files.
Unfortunately, the list doesn't specify the type of change for each file: added, modified or deleted ... etc
How may I display a list of changes [type of change, file name] in a given SHA of a specific commit.