Search notes:

git show

Show various types of objects.
git show object-hash
git show HEAD:path/to/file.txt
git show HEAD^:path/to/file.txt
git show branch:path/to/file.txt

Quickly show content of a file at a given commit

The following command prints the content of the file hello.c as stored in the repository with the commit id d6c60eb48. Note the colon between the commit id and the filename!:
git show d6c60eb48:hello.c
Compare with git cat-file.

Redirecting output in PowerShell 5.1

By default, the redirection operators (>, >> etc.) of PowerShell use UTF16-LE as default encoding.
Thus, in such an environment, the output should probably be sent to a file by explicitly stating the desired encoding with the -encoding parameter:
git show d6c60eb48:hello.c | out-file -encoding utf8 hello.old-version.c

Show file of a given branch in GVIM

The content of path/to/file.c, as being stored in the branch V1.1-fixes, can be shown in gvim by using the - argument of gvim:
git show V1.1-fixes:path/to/file.c | gvim -

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>

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

See also

git cat-file, git restore
git commands

Index