Display every modified file in git repository.

Clone a sample repository that will be used in this example.

$ git clone ssh://github.com/milosz/git-modified-files-example.git
Cloning into 'git-modified-files-example'...
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 14 (delta 1), reused 14 (delta 1), pack-reused 0
Receiving objects: 100% (14/14), done.
Resolving deltas: 100% (1/1), done.

Change working directory.

$ cd git-modified-files-example

Display commit logs.

$ git log
commit c6151fa7ab83b79843448efafeb6cc0ea409d51e (HEAD -> main, origin/main, origin/HEAD)
Author: Milosz Galazka <milosz@sleeplessbeastie.eu>
Date:   Fri Jun 25 00:44:50 2021 +0200

    added script.sh

commit 692c6111ee5aba3d212986d43e925b1bd344bf18
Author: Milosz Galazka <milosz@sleeplessbeastie.eu>
Date:   Fri Jun 25 00:44:50 2021 +0200

    updated readme file

commit 83aacbcd57d2f27deb2be102c9f49e032c800115
Author: Milosz Galazka <milosz@sleeplessbeastie.eu>
Date:   Fri Jun 25 00:44:50 2021 +0200

    renamed readme.txt to readme.md

commit 1beb20adefab102ee6da6648ca3c715fe3fba693
Author: Milosz Galazka <milosz@sleeplessbeastie.eu>
Date:   Fri Jun 25 00:44:50 2021 +0200

    added initial header

commit 2201d6994c384f638f8e2c7812259089c81bda6f
Author: Milosz Galazka <milosz@sleeplessbeastie.eu>
Date:   Fri Jun 25 00:44:50 2021 +0200

    initial import

Display every modified file.

$ git diff --name-only  $(git rev-list HEAD | tail -n 1)
readme.md
readme.txt
script.sh

Display every modified file with its status.

$ git diff --name-status  $(git rev-list HEAD | tail -n 1)
A       readme.md
D       readme.txt
A       script.sh

Display every modified file in the most recent commit.

$ git diff --name-only HEAD^
script.sh

Display every modified file with its status in the most recent commit.

$ git diff --name-status HEAD^
A       script.sh

Display files modified between two commits.

$ git diff --name-only 83aacbcd57d2f27deb2be102c9f49e032c800115 692c6111ee5aba3d212986d43e925b1bd344bf18 
readme.md

Display files modified between two commits with their status.

$ git diff --name-only 83aacbcd57d2f27deb2be102c9f49e032c800115 692c6111ee5aba3d212986d43e925b1bd344bf18 
M       readme.md

Additional notes

Use the following script.sh to play with it.

#!/bin/bash

git init

touch readme.txt
git add readme.txt
git commit -m "initial import"

git checkout -b TRACK-1250 master
cat <<EOF | tee  readme.txt
# git diff name only example
EOF
git add readme.txt
git commit -m "added initial header"
git mv readme.txt readme.md
git commit -m "renamed readme.txt to readme.md"

git checkout master
git merge --no-edit TRACK-1250

git checkout -b TRACK-4320 master
cat <<EOF | tee readme.md
# git diff name only example
simple example to illustrate ';git diff --name-only';
EOF
git add readme.md
git commit -m "updated readme file"
git checkout master
git merge --no-edit TRACK-4320

git checkout -b TRACK-6850 master
cat <<EOF | tee script.sh
$(cat $0)
EOF
git add script.sh
git commit -m "added script.sh"

git checkout master
git merge --no-edit TRACK-6850

Excerpt from the git-diff manual page.

[...]
       --name-only
           Show only names of changed files.

       --name-status
           Show only names and status of changed files. See the description of the --diff-filter option on what the status
           letters mean.
[...]
       --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
           Select only files that are 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). Any combination of the filter characters (including none) can be used. When * (All-or-none)
           is added to the combination, all paths are selected if there is any file that matches other criteria in the
           comparison; if there is no file that matches other criteria, nothing is selected.

           Also, these upper-case letters can be downcased to exclude. E.g.  --diff-filter=ad excludes added and deleted
           paths.

           Note that not all diffs can feature all types. For instance, diffs from the index to the working tree can never
           have Added entries (because the set of paths included in the diff is limited by what is in the index).
           Similarly, copied and renamed entries cannot appear if detection for those types is disabled.
[...]