Quiz
Warm-up from lesson 2-3. You run the daily loop: edit, git add, git commit. Which step actually adds a new snapshot to the project's history?
git log
You will read history far more often than you write it: to find when a bug crept in, to see what a teammate shipped overnight, to work out why a line exists at all. All of that starts with git log, which prints the history, newest commit first:
$ git log commit c7d8e9f2a91b4c3d5e6f7a8b9c0d1e2f3a4b5c6d Author: Ada Lovelace <ada@example.com> Date: Tue Mar 3 14:12:05 2026 -0800 Add photo of finished pancakes commit a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0 Author: Ada Lovelace <ada@example.com> Date: Tue Mar 3 13:40:11 2026 -0800 Add pancake recipe
There's the full 40-character hash from lesson 1-2, plus author, date, and message for each commit. For a quick scan, most people use the condensed form:
$ git log --oneline c7d8e9f Add photo of finished pancakes a1b2c3d Add pancake recipe
One line per commit: short hash and message. If the history is long, log opens in a scrolling viewer, press q to quit it (same q as less in the terminal course).
git show and HEAD
git log lists commits, git show zooms into one:
$ git show a1b2c3d
prints that commit's author, date, message, and the exact line changes it introduced.
Run git show with no hash and it shows the commit you are currently standing on. Git's name for "where you currently are" is HEAD. Right after a commit, HEAD is that newest commit. You will see the word HEAD constantly in Git's output from now on, it always means your current position in the history.
Filtering a long history
Real projects have thousands of commits, so nobody reads git log raw for long. The flags engineers actually reach for:
git log -n 5— only the newest 5 commits.git log --author=ada— only commits whose author matches.git log --oneline --graph --all— draws the commit graph as ASCII art, all branches at once. This becomes gold once branches exist (unit 5); it is the fastest way to see the shape of a history.
Flags combine freely: git log --oneline -n 5 is a common reflex before starting the day's work.
Explore the history of the recipe-book repo, which now has two commits.
Step 1/2: Print the compact one-line-per-commit history.
Quiz
What does git log --oneline print for each commit?
Quiz
You just made a commit. What does HEAD refer to right now?
Problem
Which command lists the commits in your repository, newest first? (Two words.)