Check out this short tutorial as well: http://zsoltfabok.com/blog/2012/02/git-blame-line-history/
Basically, it guides you through a combination of git blame
and git show
to see which commits change a specific line (git blame
, as already suggested especially in David Parsson's answer) and how that line change (git show
). So, iterating on commits alternating git blame
git show
will give you the full history of a specific line of a file.
Also, don't forget git blame -M
in case you doubt the line has been copied from another file. From https://www.kernel.org/pub/software/scm/git/docs/git-blame.html
-M |num|
Detect moved or copied lines within a file. When a commit moves or copies a block of lines (e.g. the original file has A and then B, and the commit changes it to B and then A), the traditional blame algorithm notices only half of the movement and typically blames the lines that were moved up (i.e. B) to the parent and assigns blame to the lines that were moved down (i.e. A) to the child commit. With this option, both groups of lines are blamed on the parent by running extra passes of inspection.
num is optional but it is the lower bound on the number of alphanumeric characters that git must detect as moving/copying within a file for it to associate those lines with the parent commit. The default value is 20.