git log
The `git log` command shows the commit history of a repository, listing commits from newest to oldest. Each entry includes the commit hash, author, date, and message.
Git log has many useful options for filtering and formatting history, such as showing a compact one-line summary per commit or filtering by author or date range.
git log
git log --oneline
git log --graph --onelineBasic log output
By default, git log shows the full hash, author, date, and message for every commit, which can be long. Press 'q' to exit the paginated view.
Useful log options
`git log --oneline` shows a compact summary. `git log --graph` visualizes branches. `git log -n 5` limits output to the last 5 commits.
git log --oneline9c2e1aa Fix crash when cart is empty
4d1f0bb Refactor auth module
a3f5c9e Add login validationShows each commit as a short hash and summary message on a single line.
git log -n 2commit 9c2e1aa...
Author: Alex Smith
Date: ...
Fix crash when cart is empty
commit 4d1f0bb...
...Limits the output to the two most recent commits with full details.
Key points
- git log shows commit history, newest first.
- --oneline compresses each commit to a single summary line.
- -n <number> limits how many commits are shown.
- --graph visually shows how branches diverged and merged.
