Show changed files of a given commit
In order to see a summary (statistics) of changed files of a given
commits, one of the following command can be used:
git show --stat <commit-sha>
git show --stat --pretty=%gd <commit-sha>
Using --name-only
combined with --pretty=format:
prints only the file names (@
refers to the last commit):
git show --name-only --pretty=format: @
This is ideal for pipelines, for example:
git show --name-only --pretty=format: @ | xargs touch
Error message - fatal: path '…' exists on disk, but not in '…'
The error message fatal: path '…' exists on disk, but not in '…' might be caused when using backslashes rather than forward slashes to separate directories:
PS: > git show master:path\to\file.txt
fatal: path 'path\to\file.txt' exists on disk, but not in 'master'
# better:
PS: > git show master:path/to/file.txt