Lessons · Git · reading the history
Reading the history
git log lists commits newest first: hash, author, date, message. --oneline compresses each to one line; --graph --all draws every branch.
Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.
What it is for
Before touching anything you did not write, read the log. It says who changed what and, with good messages, why. It is also how you find the hash for revert, cherry-pick and blame.
How to think about it
Start with --oneline for the shape, -p for the detail of one commit, --graph --all when branches are involved. Limit with -5 rather than paging through everything.
Worked example
git log --onelineOne line per commit, newest first: short hash and subject.
git log --oneline -5The last five only.
git log --graph --oneline --allEvery branch as text art, with the merge points.
git log -p -1The last commit with its full diff.
Your turn
The history, one line per commit.
git log
Try it in a real repository
The trap
git log shows the history reachable from HEAD. A commit on another branch is not missing; add --all to see it.