Skip to content
Latchkey

git log: Usage, Options & Common CI Errors

git log walks the commit history from a starting point, formatted however you need.

Log is the workhorse for inspecting history and generating changelogs. Custom --pretty formats keep output stable for scripts.

What it does

git log lists commits reachable from a given ref (HEAD by default), in reverse-chronological order, with configurable formatting and filtering.

Common usage

Terminal
git log --oneline --graph --decorate
git log -n 5
git log --pretty=format:"%h %s (%an)"
git log main..feature         # commits in feature not in main
git log --since="2 weeks ago" -- path/

Options

FlagWhat it does
--onelineOne compact line per commit
--graphASCII branch/merge graph
--pretty=format:<fmt>Custom, stable output format
-n <count> / -<count>Limit number of commits
--since / --until / --authorFilter by date or author

Common errors in CI

fatal: your current branch 'main' does not have any commits yet - a fresh repo. With a shallow clone, log shows only the fetched commits, so a range like main..feature can look empty or wrong; deepen with git fetch --unshallow or fetch-depth: 0.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →