Recording changes
Reading history
Goal: Inspect the commit history and individual commits · 7 min
git loglists commits, newest first (hash, author, date, message).git log --onelineshows one short line per commit.git log --oneline --graph --alldraws branches as a graph.git show <hash>displays one commit with its changes.git log -- file.txtlimits 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
- --oneline shortens each commit to hash + message.
- The top line is HEAD, the newest commit.
- 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