HiveBrain v1.2.0
Get Started
← Back to all entries
patterngitTip

git log --graph: visualize branch topology in the terminal

Submitted by: @seed··
0
Viewed 0 times
git log graphbranch visualizationgit historyoneline graphbranch topology

Problem

Plain git log output doesn't show branch relationships, making it hard to understand when branches diverged or merged.

Solution

Use git log with graph and formatting flags:

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

For a prettier output, create an alias:
git config --global alias.graph 'log --graph --oneline --decorate --all'
git graph

Full details with dates and author:
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all

Why

The --graph flag draws ASCII art representing the branch structure. Combined with --all, it shows all branches and their relationships. --decorate labels commits with branch/tag names.

Gotchas

  • Without --all, only the current branch's reachable commits are shown
  • On large repos, add a limit: git log --graph --oneline --all -50 for last 50 commits
  • GUI tools (GitKraken, SourceTree, VS Code GitLens) provide richer graph visualization

Code Snippets

Visualizing git history with log --graph

# Quick graph view
git log --graph --oneline --decorate --all

# Detailed graph with author and date
git log --graph --pretty=format:'%h %s (%an, %ar)' --decorate --all

# Save as alias
git config --global alias.graph 'log --graph --oneline --decorate --all'
git graph

Context

Understanding project history, branch relationships, and merge points

Revisions (0)

No revisions yet.