LinuxCommandLibrary

git-rev-list

List commit objects in reverse chronological order

TLDR

List all commits on the current branch

$ git rev-list [HEAD]
copy

Print the latest commit that changed (add/edit/remove) a specific file on the current branch
$ git rev-list [[-n|--max-count]] 1 HEAD -- [path/to/file]
copy

List commits more recent than a specific date, on a specific branch
$ git rev-list --since "[2019-12-01 00:00:00]" [branch_name]
copy

List all merge commits on a specific commit
$ git rev-list --merges [commit]
copy

Print the number of commits since a specific tag
$ git rev-list [tag_name]..HEAD --count
copy

SYNOPSIS

git rev-list [options] [<commit>...] [-- <path>...]

PARAMETERS

--all
    List all refs as if on command line

--branches[=pattern]
    All branches matching pattern

--tags[=pattern]
    All tags matching pattern

--remotes[=pattern]
    All remote-tracking branches matching pattern

--glob=glob
    All refs matching glob

--reflog
    All reflog entries

--not
    Exclude refs specified after it

--stdin
    Read refs from stdin

--quiet
    Don't print anything to stderr

--max-count=n
    Limit to first n commits

--skip=n
    Skip first n commits

--since=time
    Commits after timestamp

--until=time
    Commits before timestamp

--author=pattern
    Commits by author matching pattern

--committer=pattern
    Commits by committer matching pattern

--grep=pattern
    Commits with log message matching pattern

--invert-grep
    Invert --grep matches

--regexp-ignore-case
    Case-insensitive regex matching

--all-match
    All patterns must match

--parents
    Print parent commits

--children
    Print child commits

--left-right
    Mark left (<) or right (>) side of symmetric range

--full-history
    Don't prune merges

--dense
    Show all commits in history

--merges
    Only merge commits

--no-merges
    Exclude merge commits

--first-parent
    Follow only first parent

--date-order
    Sort by date

--topo-order
    Topological order

--cherry-mark
    Mark equivalent commits

--right-only
    List only right side of range

--left-only
    List only left side of range

--pretty[=format]
    Pretty-print with format

--no-walk
    Don't walk commit ancestry

--ignore-missing
    Ignore missing objects

DESCRIPTION

git rev-list is a core plumbing command in Git, designed for scripts rather than direct user interaction. It outputs a list of commit SHAs (one per line) reachable from specified commits or refs, in reverse chronological order (newest first). Unlike git log, which is a porcelain command with formatted human-readable output, git rev-list provides machine-parsable output, making it ideal for counting commits, generating revision lists for other Git tools, or scripting repository analysis.

It supports powerful revision selection using Git's revision range syntax (e.g., master..HEAD, ^v1.0), path limiting, and filtering by author, committer, date, or log message. Options allow topological sorting, cherry-picking marks, or traversal of reflogs and other refs. Common uses include git shortlog (wraps it), pre-push hooks, or bisect scripts. Output can be customized with --pretty or --stat, but defaults to raw SHA-1s for stability.

Key strength: efficient traversal of large histories with options like --max-count or --skip. It's sensitive to --no-walk for listing without traversal. Always prefer it over parsing git log in scripts due to reliable, versioned output format.

CAVEATS

Plumbing command: output format subject to change; avoid in user-facing tools. Does not follow symrefs by default. Large repos may require --max-count for performance.

REVISION RANGES

Supports Git revision specs: A..B (commits in B not A), A...B (symmetric difference), ^A (exclude A), A~3 (3rd parent back).
Use --not for exclusion.

DEFAULT OUTPUT

One SHA-1 hex per line (40 chars).
Empty line on EOF. Use --count for just a number.

PATH LIMITING

-- <path> limits to commits touching paths; implies tree walk.

HISTORY

Introduced in Git v1.0.0 (2005) by Linus Torvalds as essential plumbing for listing revisions. Evolved with Git's revision syntax; key for tools like git bisect and git rebase. Stabilized in v1.5+ with extensive filtering options.

SEE ALSO

Copied to clipboard