TutreNews Learn

Recording changes

Reading history

Goal: Inspect the commit history and individual commits · 7 min

  • git log lists commits, newest first (hash, author, date, message).
  • git log --oneline shows one short line per commit.
  • git log --oneline --graph --all draws branches as a graph.
  • git show <hash> displays one commit with its changes.
  • git log -- file.txt limits the history to one file.

HEAD is a pointer to the commit you currently have checked out — usually the latest commit of your current branch. HEAD~1 means "one commit before HEAD", HEAD~2 two before.

Worked example: Compact history

  1. --oneline shortens each commit to hash + message.
  2. The top line is HEAD, the newest commit.
  3. git show displays the change of one commit.
$ git log --oneline
9c1e2f0 Add about page
4b7d3a1 Fix header colour contrast
1a0f5e9 Initial commit
$ git show 4b7d3a1