git-annotate
Show commit author and revision for each line
TLDR
Print a file with the author name and commit hash prepended to each line
Print a file with the author email and commit hash prepended to each line
Print only rows that match a regex
SYNOPSIS
git annotate [options] [rev-range] [--] <file>
git annotate --contents=<file> [options] [rev-range] [--] <file>
PARAMETERS
-h, --help
Display help and exit
-c, --abbrev[=n]
Use core.abbrev setting or n digits for commit hash
-l, --long
Show full 40-character commit hash
-t
Show raw timestamp (seconds since epoch)
-S <revs-file>
Use revisions from file
-p, --porcelain
Machine-readable porcelain format
--porcelain=v2
Extended porcelain v2 format
-L <start,<end>, -L </regex>
Annotate specific line range or regex match
-C[-<p>]
Detect line copies from other files
-M[-<p>]
Detect line moves within or across files
-O <prio,-C|M>
Priority for copy/move detection
-w
Ignore whitespace differences
--color-lines / --color-first
Colorize output by age or commit
--contents=<file>
Annotate from given file contents
-e, -s, --email, --show-email
Show email instead of author name
-g, --show-graph
Show graph beside author
DESCRIPTION
The git annotate command annotates each line of a file with the revision, author, and timestamp of the last commit that modified that line.
It is particularly useful for understanding code changes, identifying who introduced a bug, or tracing the evolution of specific code sections. Output shows the commit hash (abbreviated), author name, timestamp, and the line content.
By default, it uses the working tree file or specified revisions. It detects moved or copied lines with options like -C or -M. Color output highlights different authors.
Note: git annotate is a porcelain command (user-facing) and a deprecated synonym for git blame, which offers identical functionality with more options and active maintenance.
CAVEATS
Deprecated synonym for git blame; use git blame instead. Output format may change as it's porcelain. Large files or repos slow performance. Ignores uncommitted changes unless -C/-M used.
OUTPUT EXAMPLE
^1a2b3c4 (author 2023-01-01 10:00:00 +0000 1) line one 5d6e7f8 (author2 2023-02-01 12:00:00 +0000 2) modified line
ALIAS NOTE
git annotate == git blame; modern Git docs focus on blame with identical syntax/options.
HISTORY
Introduced in early Git (v1.4.0, 2006) as porcelain frontend to blame algorithm from annotate.c. Deprecated in favor of git blame around Git 1.7+ but retained for compatibility. Evolved with copy/move detection (Git 1.6+), line-range support (1.7+), and porcelain v2 (2.24+).
SEE ALSO
git blame(1), git log(1), git diff(1), git show(1)


