Course contentsShow
← Software Engineering
Lesson 66 of 1,9332. Version Control with GitFree lesson

Viewing and Navigating History with git log

Master git log options to filter, format, and search commit history effectively for understanding project evolution.

Viewing and Navigating History with git log

You'll learn how to use powerful git log options to filter, search, and format your project's commit history beyond the basic log view.

Beyond Basic Logging

You've already seen git log display commit history. Now you'll discover how to make it truly useful for understanding how your project evolved. Think of git log as a search engine for your repository's timeline—with the right filters, you can find exactly what you need among hundreds or thousands of commits.

Essential Filtering Options

Limit by count:

git log -5

Shows only the last 5 commits (replace 5 with any number).

Filter by date:

git log --since="2 weeks ago"
git log --until="2024-01-01"

Filter by author:

git log --author="Alice"

Search commit messages:

git log --grep="bug fix"

Finds commits whose messages contain "bug fix".

Formatting for Readability

One line per commit:

git log --oneline

Shows abbreviated hashes and first line of each message—perfect for quick scanning.

Graph view:

git log --oneline --graph --all

Visualizes branch structure with ASCII art, showing how branches diverged and merged.

Custom formats:

git log --pretty=format:"%h - %an, %ar : %s"

Creates custom output (hash, author name, relative date, subject).

Combining Options

The real power comes from combining filters:

git log --oneline --author="Bob" --since="1 month ago" --grep="feature"

This finds Bob's commits from the last month containing "feature" in the message.

Key Takeaway: Mastering git log options transforms commit history from an overwhelming list into a searchable, understandable record of your project's evolution—essential for debugging, code review, and understanding why changes were made.