Git 2 reference · Basics

git show Command (Git)

Show a commit's message and changes, or the contents of a file at any commit with COMMIT:PATH.

Git 2

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

git show [COMMIT] [COMMIT:PATH]

Parameters

ParameterDescription
--stat Changed files only.
HEAD~1:file A file as it was one commit ago.
--format= Hide the commit header.

Examples

A commit and its files
git init -q -b main app && cd app
echo '# Shop' > README.md
git add README.md && git commit -q -m 'Initial commit'
echo 'price=9' > config.ini; git add .; git commit -q -m 'Add config'
git show --stat --format='%h %s' HEAD

Output

bd0e761 Add config

 config.ini | 1 +
 1 file changed, 1 insertion(+)

Run this on your computer — see “Get Started” for setup.

A file from an earlier commit
git init -q -b main app && cd app
echo '# Shop' > README.md
git add README.md && git commit -q -m 'Initial commit'
echo v1 > app.txt; git add .; git commit -q -m v1
echo v2 > app.txt; git commit -q -am v2
git show HEAD~1:app.txt

Output

v1

Run this on your computer — see “Get Started” for setup.

Was this page helpful?