Git Reference ยท Inspecting History
git log command
Reference for git log: show commit history, filter by author, date, message or path, draw the graph, follow renames, and choose the output format.
git log lists the commits reachable from the revisions you name (by default HEAD), newest first. It is the main way to read history: who changed what, when, and why. By default it prints the full ID, author, date and message of every commit, in a pager when the output is long.
Almost everything is an option. Some options choose which commits to show (by count, date, author, message, path, ancestry), some choose how each commit is displayed (one line, graph, diffs, statistics), and some control the order. They combine freely, which is what makes git log so useful for answering specific questions about a project.
git log [<options>] [<revision-range>] [[--] <path>...]
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
git log [<options>] [<revision-range>] [[--] <path>...]
<revision-range> can be one revision (everything reachable from it), A..B, A...B, or several revisions with --not / ^rev. Paths after -- limit the history to commits that touch them.
Selecting commits
| Option | Description |
|---|---|
-<n>, -n <n> |
Show at most n commits. |
--skip=<n> |
Skip the first n commits. |
--since=<date>, --until=<date> |
Commits newer or older than a date. Aliases: --after, --before. |
--author=<regex>, --committer=<regex> |
Match the name or email. |
--grep=<regex> |
Match the message. Repeat for OR; --all-match makes it AND; --invert-grep negates; -i ignores case; -E/-F choose regex type. |
--merges, --no-merges |
Only merges, or none. Short for --min-parents=2 and --max-parents=1. |
--first-parent |
Follow only the first parent of merges. |
--ancestry-path |
In a range A..B, keep only commits on a path from A to B. |
--all, --branches, --tags, --remotes |
Start from all refs or a class of refs. |
--follow |
Follow the history of a single file across renames. |
-S<text>, -G<regex>, -L<range>:<file> |
Search by changes in the diff or by line range (see git log -S and -G). |
--diff-filter=<ACDMRTUXB> |
Only commits with such file changes (Added, Deleted, Modified, Renamed, ...). |
Display and order
| Option | Description |
|---|---|
--oneline |
Short ID and subject on one line. |
--graph, --decorate, --source |
ASCII graph of the history; branch and tag names; the ref each commit was reached from. |
--pretty=<format>, --format=<format> |
Choose the layout (see git log --pretty). |
--date=<format> |
short, iso, relative, format:<strftime> and more. |
-p, --stat, --shortstat, --numstat, --name-only, --name-status |
Add the patch or a summary of changed files. |
--left-right |
Mark commits with < or > for symmetric ranges. |
--reverse |
Oldest first. |
--topo-order, --date-order, --author-date-order |
Order commits by graph topology or timestamp. |
--show-signature |
Verify and show signatures. |
Returns: exit status 0 even when nothing matches; non-zero for errors such as an unknown revision.
Usage notes
- A date without a time is read at the current time of day, so
--since=2026-01-03can miss a commit made earlier that day. Write a full timestamp ("2026-01-03 00:00") when precision matters. - Path limiting hides merges unless they changed the path, and it simplifies history. Add
--full-historyif commits seem to be missing. - Merge commits show no diff by default. Add
-m,-c,--ccor--first-parent -pto see their changes. --followworks with exactly one file and is a heuristic based on content similarity.- Log order is by commit date unless you ask for topological order. Use
--topo-orderwhen parents must appear after children. - Output goes to the pager (
core.pager) only on a terminal. Scripts get plain text and should use--formatwith-zfor safe parsing. git logshows what is reachable, not what once existed. Deleted branches and rewritten commits live in the reflog.- Config:
log.date,log.decorate,log.abbrevCommit,log.showSignatureandlog.mailmapchange the defaults. - Cost: walking all history is fast; combining
-p,-S,-G,-Lor--followwith a huge repository is not. The commit-graph file speeds up most walks.