git-annotate - Linux


git-annotate is a powerful Git command used to annotate lines of a file with information about the commit, author, date, and commit message associated with each line change. It provides a detailed historical record of a file’s evolution.


git annotate [options] <file>


  • -a, –all: Show annotations for all lines.
  • -f, –follow: Annotate the code in a specified revision and follow it across renames.
  • -L : Limit annotations to the specified line range.
  • -n, –numstat: Print line numbers and optionally the count of insertions and deletions.
  • -S : Only annotate lines matched by the regex.
  • –first-parent: Only show the first parent commit for each line.
  • –max-count : Limit the number of commits shown for each line.
  • –since, –until: Filter annotations by commit date.


Basic usage:

git annotate

Annotations for a specific revision:

git annotate -f <commit-id>

Annotations within a line range:

git annotate -L 10-20

CSV output with line additions:

git annotate -n > output.csv

Common Issues

  • Wrong commit history: Ensure the git history is accurate and complete.
  • Large files: Annotating large files can be slow; consider using the -a option with caution.
  • Missing dates: If commit dates are not shown, check if the --first-parent option is enabled.


  • git blame: Blame lines to a specific committer and date.
  • git difftool: View annotation differences between revisions.
  • git grep: Search for a pattern across annotations.

Related Commands