The command everyone copies
If you have ever Googled "pretty git log", you have probably copied a variation of this command:
git log --all --graph --decorate --oneline
It draws an ASCII graph of all branches and tags, one commit per line, decorated with reference names. It is the single most useful read-only Git command.
Anatomy
--all- include every branch and tag, not just HEAD's ancestry.--graph- draw the parent/child graph in ASCII.--decorate- annotate commits with branch and tag names.--oneline- shorthand for--pretty=oneline --abbrev-commit.
Better formatting
For colour and a richer pretty format:
git log --all --graph \
--pretty=format:'%C(yellow)%h%Creset %C(cyan)%an%Creset %s %C(green)(%cr)%Creset%C(red)%d%Creset' \
--abbrev-commit
Yellow short SHA, cyan author, plain subject, green relative date, red refs.
Make it an alias
git config --global alias.lg "log --all --graph --pretty=format:'%C(yellow)%h%Creset %C(cyan)%an%Creset %s %C(green)(%cr)%Creset%C(red)%d%Creset' --abbrev-commit"
Now git lg works everywhere.
Filtering
git lg -20 # last 20 across all branches
git lg --since='2 weeks ago'
git lg --author='Jane'
git lg --grep='OAuth'
git lg -- src/checkout.js # only commits touching this file
First-parent only
For the trunk-only view (skipping merged feature branches' interiors):
git log --first-parent --oneline main
Useful for release notes - one commit per merged feature, no internal branch noise.
The full graph for a feature
git log --graph --boundary main...feature/oauth
... shows commits reachable from either ref but not both - the symmetric difference. --boundary includes merge bases as outline commits.
Live graph viewers
Beyond the CLI, tig, gitk, GitHub's network graph, GitLens, GitKraken, and Sublime Merge all visualise the same graph. Use the CLI to grok structure quickly; reach for a GUI when the graph gets dense.
tig --all
gitk --all
Performance
On very large repos, --all is expensive. Combine with -n to limit:
git log --all --graph --oneline -n 100
The teaching aid
When pairing or onboarding, "git lg" is the fastest way to convey the actual shape of a repo's history. Long-running branches, merge points, abandoned experiments - all visible in seconds. Memorise the alias; share it.