git blame

Find out who last changed each line of a file, and in which commit

What it does

git blame prints a file line by line, each with the short hash, author and date of its last change. That is how you find when and why an odd line appeared: open its commit with git show and read the message.

-L limits the output to a range of lines, for example -L 10,20. Despite the name, it is not about finding someone to blame: it is the fastest way to understand the history of the code.

Syntax

git blame <file>
git blame -L <start>,<end> <file>

Examples

Related commands

Practise · All commands