Git log is your project's timeline. It lists all commits from the beginning of the repository to the present, ordered from newest to oldest.
Git log — along with its parameters — answers the core Version Control System (VCS) questions: who changed what, when, and why.
How to Use Git Log
The simplest way to use git log is to run the following command in your terminal:
git log
This lists the full commit history of your current repository. For a cleaner output, this is the more common way to run it:
git log --oneline --graph
Press q to exit the log view.
What Does a Git Log Output Look Like?
Running git log in its simplest form shows the following for each commit:
- commit hash: A unique identifier for each commit.
- author: The name and email of the person who made the change.
- date: The exact date and time the commit was made.
- commit message: The message describing the change. For more on writing good commit messages, see our git commit message best practices post.
Git Log Parameters and Usage (With Examples)
Running git log without any parameters can flood your terminal fast. Parameters let you narrow down and format the output to exactly what you need. The command has a rich set of options — not because the others are useless, but because different situations call for different tools. We can group git log parameters into four categories: formatting (Visuals), filtering, content analysis (Deep Dive), and structural. Here are the most commonly used ones:
Parameters can be combined freely. For example: git log --oneline --graph --author="Alice" --since="1 week ago" shows everything Alice committed in the last week, in a compact graph format.
Most commonly used combination:
git log --oneline --graph --decorate --all
1- Git Log Formatting (Visuals) Parameters
- Compact view:
git log --onelineFits each commit on a single line, showing the short hash and commit message. - Visual branch tree:
git log --graphRenders branching and merging as an ASCII tree in your terminal. It's as close to ASCII art as the command line gets. Try it in the Git Simulator. - Show branch and tag labels:
git log --decorateAdds branch and tag pointers to each commit in the output.
2- Git Log Filtering Parameters
- By date:
git log --since="1 month ago"orgit log --after="2026-04-01" --before="2026-04-15"—aftersets the start date,beforesets the end date. - By author:
git log --author="Name"lists commits from a specific person only. - By message:
git log --grep="fixed bug"filters commits whose messages contain the given keyword. - By file:
git log -- path/to/filefocuses the history on a specific file — useful for seeing who changed what and when. - By count:
git log -n 5returns only the last 5 commits.
3- Git Log Content Analysis (Deep Dive) Parameters
Use these when you need to see not just what was committed, but what actually changed in the code.
- Show code changes:
git log -por--patchdisplays the full diff for each commit, line by line. - Summary stats:
git log --statshows which files changed and how many lines were added or removed. - Search by code content:
git log -S "function_name"is one of git's most powerful features. Say you changed a function and can't remember when — this finds the commits where that exact string was added or removed. It searches code content, not commit messages. - Track a function's history:
git log -L :function_name:file.jstraces the full history of a specific function across all commits.
4- Git Log Structural Parameters
Use these to understand the architectural flow of a project and the relationships between branches.
- Hide merge commits:
git log --no-mergesremoves merge commits from the output for a cleaner history. - Show only merge commits:
git log --mergesdoes the opposite — useful for reviewing major integration points. - All branches:
git log --allincludes commits from all local and remote branches, not just the current one.
What is Git Log Used For?
Rolling back: When something breaks and you need to travel back in time, git log is where you start.
Accountability: It's the answer to "who wrote this?" — no guessing required.
Documentation: Combined with well-written commit messages, it becomes a readable changelog of your entire project.
Git log is your project's black box. You rarely look at it when everything works — but the moment something breaks, it's the first place you go. It's not just a list; it's a microscope for your codebase.
Git Log vs Reflog: What's the Difference?
Git log shows the commit history of the repository — the "official record" shared with your team. Git reflog, on the other hand, tracks your local HEAD movements: branch switches, resets, rebases, and more. This makes it possible to recover accidentally deleted branches or reverted commits.
Pro tip: If you can't find a commit you thought was gone, check git reflog first.
In short:
- git log → commit history (the shared, public record)
- git reflog → local HEAD history (only on your machine)