Hone

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 --oneline
One line per commit, newest first: short hash and subject.
git log --oneline -5
The last five only.
git log --graph --oneline --all
Every branch as text art, with the merge points.
git log -p -1
The last commit with its full diff.

Your turn

The history, one line per commit.

git log 

The trap

git log shows the history reachable from HEAD. A commit on another branch is not missing; add --all to see it.

Practise reading the history on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.