git-blame
Show who modified each line of a file
TLDR
Print file with author name and commit hash on each line
Print file with author email and commit hash on each line
Print file with author name and commit hash on each line at a specific commit
Print file with author name and commit hash on each line before a specific commit
Jump to the parent of a specific commit and track a specific text and 10 of its following lines
Print author name and commit hash information for a specific line range
Ignore whitespaces and line moves
SYNOPSIS
git blame [options] [<rev-range>] [--] <path>...
Common: git blame [-L <line-range>] [-p] [-w] [-C] <file>
PARAMETERS
-L
Limit annotation to specified line range (e.g., 10,20; +5,3; /^func/,/^}/).
-l, --long-format
Show full 40-char SHA-1 commit hash.
-t, --abbrev=(n)
Show only SHA-1; optional n chars.
-S
Use rev-list output from file for blame computation.
-p, --porcelain
Machine-readable porcelain format.
--porcelain=v2
Extended porcelain v2 format with boundary commits.
-w, --ignore-whitespace
Ignore whitespace for line matching.
-C[-
Detect/score lines copied/moved from other files.
-C -C
Scan twice for cross-file copies (expensive).
-M[
Detect lines moved/copied within same file.
-D
Similarity threshold (0-100) for -C/-M.
-a, --show-all
Annotate any preceding trailer lines too.
-s
Suppress author name and timestamps.
-e
Use author email instead of name.
-b, --no-author
Disable whitespace breakdown heuristics.
-O
Order blame output per file's instructions.
--ignore-rev
Ignore commits matching this rev.
--ignore-revs-file
Ignore revisions listed in file.
--contents
Blame from named file, not working tree.
--color-lines
Color by commit signature.
--color
Color output: always, never, auto.
DESCRIPTION
git blame (also known as git annotate) is a Git command that attributes each line in a file to the commit and author who last modified it. It provides commit hash, author name, authorship timestamp, and commit timestamp for every line, helping developers trace code origins, debug issues, and review contributions.
By default, it annotates from the working tree or specified revision, processing backwards through history. Output is formatted in columns: commit (7 chars), author, time summary, line content. It's crucial for understanding code evolution in large projects.
Key uses include finding bug introducers (e.g., git blame -L 100,+10 buggy.c), ignoring whitespace (-w), or detecting copy/move (-C, -M). Porcelain modes enable scripting. While powerful, it skips binary files and can be slow on massive histories without limits.
CAVEATS
Slow on large repos/files with long histories; no binary support; -C/-M can be CPU-intensive; output assumes text files.
REVERSE BLAME
Find line introduction: git blame --reverse START..END -- <file>.
EMAIL BLAME
For mailing lists: git blame -cme <file> uses committer metadata.
HISTORY
Introduced by Linus Torvalds in Git v0.99 (April 2005), as an early core command for line-level attribution. Evolved with copy-detection (-C/-M) in Git 1.6 (2008), porcelain v2 in 1.7 (2010), and ignore-revs in 2.23 (2019). Widely used in open-source for accountability.
SEE ALSO
git annotate(1), git log(1), git show(1), git rev-list(1)


