Get a list of changed files and their status for a specific Git commit

Ashraf Bashir picture Ashraf Bashir · Jul 17, 2014 · Viewed 21.5k times · Source

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.

Answer

Joe picture Joe · Jul 18, 2014

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).