Git (Version Control) - View commit details using the git show command

by
Jeremy Canfield |
Updated: September 28 2022
| Git (Version Control) articles
The git show command can be used to view information about a commit. The git show HEAD command can be used to display information about the latest commit.
]$ git show HEAD
commit 66afc30ab51826565db5efe7bb7ece95827562eb
Author: John Doe <john.doe@example.com>
Date: Tue Sep 27 05:30:54 2022 -0500
replaced foo with bar
diff --git a/example.txt b/example.txt
index d6ea8b6..52934eb 100644
- foo
+ bar
Or, you can specify a specific commit.
git show <commit id>:<path to file>
The git log can be used to get the ID of each commit.
~]# git log --oneline example.txt
afba75a second commit
741785c first commit
The git show command can be used to determine the appropriate path to the file.
git show <commit id> --name-only
Which will return a result such as:
misc/example.txt
In this example, here is how to view the changes made to example.txt at first commit.
~]# git show 741785c:misc/example.txt
commit 741785c
Author: John Doe <john.doe@example.com>
Date: Tue Jan 17 07:14:54 2022 -0500
initial commit
Did you find this article helpful?
If so, consider buying me a coffee over at