git log

Show the commit history

What it does

git log lists the commits of the current branch from newest to oldest: hash, author, date and message. Long output opens page by page: scroll with the arrow keys, quit with q.

--oneline squeezes each commit into one line with a short hash and the title, -5 (or -n 5) keeps only the last five. --graph draws branches and merges, and --all shows every branch, not just the current one. Together they map the whole repository. Name a file to keep only the commits that changed it.

Syntax

git log
git log --oneline -<number>
git log --graph --oneline --all
git log <file>

Examples

Related commands

Practise · All commands