git log: the history of a project

Updated July 31, 2026

git log shows the history of a repository: commits from the newest down to the oldest, each with its author, date, and message.

The command only reads and changes nothing, so you can run it as often as you like. It is where you start with someone else's project, and it is how you hunt for the moment something broke.

$ git log
commit ab941c94a7f875743ea972f26c5d99fe172c62f4 (HEAD -> main)
Author: Anna Petrova <anna@example.com>
Date:   Tue Mar 17 11:05:19 2026 +0300

    shopping list

commit 0edf9fb16789e420e7f12ce641b2424ee33f114c
Author: Anna Petrova <anna@example.com>
Date:   Tue Mar 17 10:31:02 2026 +0300

    recipe: milk and the order of steps

The top commit is the most recent one, under it the one before, and so on down to the first. The forty characters after the word commit are the hash, the unique identifier of that snapshot; the first seven are enough in commands, git works out the rest. The HEAD -> main mark shows where you are standing. A long history goes to a pager: scroll with the space bar, quit with q.

The compact view and filters

--oneline squeezes every commit into a single line, so the whole history fits on the screen:

$ git log --oneline
ab941c9 (HEAD -> main) shopping list
0edf9fb recipe: milk and the order of steps
7cb799b recipe: first version

From there you narrow the selection with flags, and they stack:

$ git log -n 5                       # only the five most recent commits
$ git log --oneline --author=Anna    # author name or email contains "Anna"
$ git log --since=2026-03-01         # from this date on
$ git log --since=2026-03-01 --until=2026-03-18
$ git log --oneline -- report.txt    # only commits that touched this file

--graph draws the branching on the left:

$ git log --oneline --graph
*   a816435 Merge branch 'intro'
|\
| * e78a55c report: add an intro
* | 4f548f6 shopping: add eggs
|/
* ab941c9 shopping list

An asterisk is a commit, the vertical lines are branches. They split where work went on in parallel and come back together at the merge commit.

Common mistakes

Empty output in a fresh repository is not a failure: there are no commits yet, so there is nothing to print. --author matches a substring of the name and the email and it is case sensitive, so --author=anna finds commits made from anna@example.com while --author=ANNA finds nothing. The format for --since is loose: both --since=2026-03-01 and --since="2 weeks ago" work, and the time is read in your machine's time zone. If the output fills the screen and the prompt does not come back, you are in the pager: press q.

Where this is in the book

The full treatment is in Chapter 3. Three areas and your first commit. Next to it, git diff and commit message are worth a look.

To practise it by hand, take the interactive lesson Three areas and a commit.