Viewing History with 'git log'
You'll learn how to explore your project's commit history and customize what information Git shows you.
Why History Matters
Think of git log as your project's photo album. Just as you flip through photos to remember past events, git log lets you review what changed, when, and why. After creating commits (as you learned in the previous lesson), you need a way to view that history.
The Basic Command
Simply type:
git log
This displays your commits in reverse chronological order (newest first). For each commit, you'll see:
- The unique commit hash (that long string of letters and numbers)
- The author's name and email
- The date and time
- The commit message
Common Formatting Options
Git log becomes powerful when you customize its output:
git log --oneline
Shows a compact, one-line summary per commit—perfect when you just want an overview.
git log --graph
Displays a visual tree structure (you'll appreciate this more when working with branches later).
git log -3
Limits output to the last 3 commits (or any number you choose).
Filtering Your History
You can filter by various criteria:
git log --author="Your Name"
Shows only commits by a specific person—useful in team settings.
git log --since="2 days ago"
Filters by date range, helping you focus on recent work.
Key Takeaway: git log is your window into project history, offering various formatting and filtering options to help you find exactly what you need among your commits.