GIT - 4.7 Commit tailes with Log and Show
This lesson introduces the two commands that let you inspect the commit history of a Git repository: git log and git show. The starting point is a terminal in the test repository right after a commit. A quick git status confirms we are on a clean working directory, with nothing left to stage or commit.
Listing commits with git log
To prove that all the changes we made earlier are safely stored in the repository, we use git log, the command that prints the validation list:
git log
Git replies with every commit that is part of this repository, from the most recent down to the very first. Each entry follows the same structure:
- Commit ID — the long SHA-1 hash that uniquely identifies the commit.
- Author — the configured user (here, just me).
- Date — when the commit was created.
- Message — the commit message, including any multi-line text we entered through the editor.
For the last commit, we can see the full multi-line message we typed earlier using the text editor — proof that everything was correctly recorded.
Inspecting one commit in detail with git show
For more detail on a single commit, we use git show:
git show
By default it targets the latest commit (HEAD) and displays the same metadata as git log (ID, author, date, message), followed by a complete diff showing exactly which lines were added or removed. Passing a specific commit ID after git show lets you inspect any older commit the same way. Between git log for overview and git show for details, you get a complete read of your project history.
Summary
This lesson teaches how to inspect commit history and individual commits using Git's `git log` and `git show` commands. The `git log` command displays a chronological list of all commits, showing essential metadata like commit IDs, authors, dates, and commit messages—including multi-line messages entered via text editors. The `git show` command complements this by displaying a specific commit's full details along with a diff of all modifications made in that commit, providing a complete view of what changed.
Key points
- Use `git log` to view the entire commit history with commit IDs, authors, dates, and messages
- Commit entries in `git log` display multi-line messages that were entered via text editor during commit creation
- Use `git show` to view the most recent commit plus its full diff showing all file modifications
- `git log` and `git show` work in conjunction to provide both historical overview and detailed commit inspection
- Git log entries begin with the commit ID, followed by author information, timestamp, and the complete commit message
FAQ
What information does `git log` display for each commit?
Git log displays the commit ID, author name, date, and the complete commit message (including multi-line messages). This information is ordered chronologically from newest to oldest commits.
How does `git show` differ from `git log`?
`git show` displays the most recent commit along with a detailed diff showing all file modifications in that commit, whereas `git log` only lists commit metadata without showing the actual changes made.
Can you view multi-line commit messages in `git log`?
Yes, `git log` fully displays multi-line commit messages that were entered using a text editor during the commit creation process.