Menu
Coddy logo textTech

Git Log

Last updated

git log shows the commit history of your current branch, newest first - each commit's hash, author, date, and message. A handful of flags make it far more useful: --oneline for a compact view, --graph to see branch structure, and filters to focus on one author, file, or date range.

Try these in the terminal playground - a real shell in your browser, nothing to install.

git log walks the commit history newest-first - hash, message, and where HEAD and the branches point.

Syntax

CommandWhat it does
git logFull commit history, newest first
git log --onelineOne compact line per commit
git log --oneline --graph --allCompact history with a branch graph
git log -n 5Show only the last 5 commits
git log --author="Ada"Filter by author
git log -- file.txtHistory of a single file
git log -pShow the changes in each commit

Common cases

GoalCommand
A quick overviewgit log --oneline
See branch/merge structuregit log --graph --oneline --all
What changed in a file over timegit log -p -- file.txt
Commits since a taggit log v1.0..HEAD

Git log FAQ

How do I view commit history in Git?
Run git log. It lists commits on the current branch from newest to oldest, showing each commit's hash, author, date, and message. Press space to page through and q to quit. Add flags like --oneline to make it more compact.
What does git log --oneline do?
It condenses each commit to a single line - a short hash plus the message summary - so you can scan a lot of history quickly. Combine it with --graph --all to also see how branches diverged and merged in an ASCII graph.
How do I see the history of a single file?
Run git log -- <file> to list the commits that touched that file, or git log -p -- <file> to also show the actual changes each commit made to it. The -- separates paths from other arguments so Git doesn't confuse a filename with a branch name.
How do I filter the log by author or date?
Use git log --author="name" to show one author's commits, and --since / --until for a date range (for example git log --since="2 weeks ago"). These filters combine, so you can narrow the history to exactly what you're looking for.
Can I practice this online?
Yes. Open the terminal playground to run git log in a real shell in your browser - nothing to install. Coddy's free interactive Git course also covers inspecting history step by step.
Coddy programming languages illustration

Learn Git with Coddy

GET STARTED