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.
Syntax
| Command | What it does |
|---|---|
git log | Full commit history, newest first |
git log --oneline | One compact line per commit |
git log --oneline --graph --all | Compact history with a branch graph |
git log -n 5 | Show only the last 5 commits |
git log --author="Ada" | Filter by author |
git log -- file.txt | History of a single file |
git log -p | Show the changes in each commit |
Common cases
| Goal | Command |
|---|---|
| A quick overview | git log --oneline |
| See branch/merge structure | git log --graph --oneline --all |
| What changed in a file over time | git log -p -- file.txt |
| Commits since a tag | git 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.