Cheat Sheets · Git Cheat Sheet · Git Log Graph — Visual Commit History in Terminal

Git Log Graph — Visual Commit History in Terminal

git log --oneline --graph --all

Compact single-line graph for all branches and tags

git log --graph --decorate --oneline -n 15

Show the last 15 commits with branch labels

git log --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset"

Colorful custom formatted log with relative dates and authors

Log graph variations

CommandFeatures
git log --oneline --graph --allCompact single-line graph for all branches and tags
git log --graph --decorate --oneline -n 15Show the last 15 commits with branch labels
git log --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset"Colorful custom formatted log with relative dates and authors

Turn the plain git log output into an ASCII branch graph showing merges, branch divergences, and commit tags right in your CLI.

Related Git recipes

FAQ

How do I create a permanent alias for this?
Run: git config --global alias.lg "log --oneline --graph --all". Then you can just type git lg.

Why is --all important?
Without --all, git log only shows commits reachable from the current branch. --all includes all local and remote branches.

How to search commit messages in the log?
Use git log --grep="search term".

Stop memorizing — build it interactively

Try log options in the Git Builder

Full reference: Git Cheat Sheet