Viewing changes across commits

Suppose we want to see what has changed over the last 3 commits. To do that we use the git diff command

git diff HEAD~3 HEAD

If we only want to see the changes to a particular file, we can add the filename at the end of the command

git diff HEAD~3 HEAD file_path/file_name.ext
Viewing the changes across commits
Viewing the changes across commits 2

Here too we can use options like --name-only or --name-status to see only the list of files that have been changed.

git diff HEAD~5 HEAD~2 --name-only
git diff HEAD~7 HEAD~4 --name-status