Git Alias to Show Last Commit with Statistics

Create a git alias that displays the most recent commit with file-level change statistics showing insertions and deletions.

Log Aliases

Detailed Explanation

Last Commit with File Stats

The last alias is a quick way to see exactly what your most recent commit changed, including per-file statistics:

[alias]
    last = log -1 HEAD --stat

Understanding the Output

This alias combines two flags:

Flag Purpose
-1 Limit output to the single most recent commit
--stat Append a diffstat showing files changed, lines added (+), and lines removed (-)

Example Output

commit a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0
Author: Alice <alice@example.com>
Date:   Mon Dec 15 10:30:00 2025 +0000

    Fix null pointer in parser module

 src/parser/tokenizer.ts  | 12 ++++++------
 src/parser/ast.ts        |  4 ++--
 tests/parser.test.ts     | 28 ++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+), 10 deletions(-)

Variants

You can add --patch (or -p) to see the full diff alongside the stats:

[alias]
    lastp = log -1 HEAD --stat --patch

Or show the last N commits by parameterizing the alias:

[alias]
    last3 = log -3 HEAD --stat

Why This Matters

The diffstat gives you an instant sense of the scope of a commit without reading the full diff. A commit touching 30 files is very different from one touching 2 files, and the stat summary makes this immediately visible.

Use Case

Use this alias right after committing to double-check what was included. It is also useful as a quick sanity check before pushing, ensuring you did not accidentally include unintended files or leave out important changes.

Try It — Git Alias Builder

Open full tool