LinuxCommandLibrary

git-annotate

Show line-by-line authorship and revision information for a file

TLDR

Show line-by-line authorship

$ git annotate [file]
copy
Annotate specific revision
$ git annotate [revision] -- [file]
copy
Show in porcelain format
$ git annotate --porcelain [file]
copy
Ignore whitespace changes
$ git annotate -w [file]
copy

SYNOPSIS

git annotate [options] [rev] [--] file

DESCRIPTION

git annotate displays line-by-line authorship information for a file, showing which commit and author last modified each line. It's functionally equivalent to git blame but uses a slightly different default output format that emphasizes revision information over authorship.
For each line in the file, the command displays the abbreviated commit hash, author name, timestamp, line number, and the actual line content. This makes it invaluable for understanding the history of changes, identifying when bugs were introduced, or determining who to ask about specific code sections.
The command supports detecting moved and copied code across files using the -M and -C options, following code even when it's been refactored or relocated. The --porcelain format provides machine-readable output suitable for parsing by scripts or tools.
While git blame is more commonly used and has become the de facto standard, git annotate remains available as an alias with historically different formatting preferences.

PARAMETERS

-L start,end

Annotate specific lines.
-w
Ignore whitespace changes.
--porcelain
Machine-readable format.
-M
Detect moved lines.
-C
Detect copied lines.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community