Course contentsShow
← Computer Science
Lesson 2189 of 2,87249. Version Control with GitFree lesson

Viewing Branch History

Use git log with various options to visualize branch structure, merge commits, and divergent histories.

Viewing Branch History

You'll learn how to use git log options to visualize complex branch structures, merge points, and divergent development paths.

The Challenge of Understanding Branching

When working with multiple branches, commits don't form a simple line—they create a graph with splits and merges. Standard git log shows commits chronologically but doesn't reveal structure: which commits belong to which branches, where branches diverged, or how merges reconnected them.

Visual Log Options

Git offers several git log flags to illuminate branch topology:

git log --graph draws ASCII art showing branch relationships:

* commit abc123 (merge commit)
|\  
| * commit def456 (feature branch)
* | commit ghi789 (main branch)
|/  
* commit jkl012 (common ancestor)

git log --oneline condenses each commit to one line, making graphs readable:

git log --oneline --graph --all

--all shows commits from all branches, not just your current one—essential for seeing the full picture.

--decorate labels commits with branch and tag names, showing where branches currently point.

Combining Options for Power

The most useful command for branch visualization:

git log --oneline --graph --all --decorate

This reveals divergent histories (parallel development), merge commits (integration points), and branch positions—like viewing a subway map instead of a timetable.

Analogy: Think of standard git log as a list of train arrivals. Adding --graph --all transforms it into a route map showing how different lines split, run parallel, and reconnect.

Key Takeaway: Use git log --graph --all --oneline --decorate to visualize branch structure, understand merge history, and see how parallel development paths evolved and reconnected in your repository.