Exercises — Stage 3: Add the Scoreboard
Exercise 1: View history in different formats
Goal: Get comfortable flipping between log views.
Steps:
- Run
git log. - Run
git log --oneline. - Run
git log --oneline --graph. - Run
git log --stat.
What happened: Each flag gives you a different angle on the same three commits. --oneline is compact, --graph draws a line between commits, --stat adds a summary of which files changed in each commit.
Exercise 2: Inspect one commit
Goal: See exactly what changed in a single save point.
Steps:
- Run
git log --onelineand copy the short hash of the Stage 2 commit. - Run
git show <hash>.
What happened: git show prints the commit message and the full diff of what that commit changed. This is how you audit old changes.
Exercise 3: Change the starting lives
Goal: Practice the edit-commit loop.
Steps:
- Change
<p>Lives: 3</p>to<p>Lives: 5</p>. - Reload the browser to see 5 lives.
- Run
git diffto review your change. - Revert with
git restore index.html(no commit needed). - Reload the browser — back to 3 lives.
What happened: git restore <file> throws away unsaved changes and brings the file back to the last committed version. Editing is risk-free when Git has your back.
Exercise 4: Count your commits
Goal: Learn how to count history programmatically.
Steps:
- Run
git rev-list --count HEAD.
What happened: rev-list --count HEAD prints the number of commits reachable from the current position. You should see 3. This is handy in scripts and CI systems.