git: history of a source code line

git is one of those tools that no matter how much you know about it, there is an infinite supply of new things to learn.  Here’s a handy bit I’ve discovered recently, thanks to this StackOverflow comment:

Since Git 1.8.4, git log has -L to view the evolution of a range of lines.


And you want to know the history of what is now line 155.

Then, use git log. Here, -L 155,155:git-web– means “trace the evolution of lines 155 to 155 in the file named git-web–“.

Absolutely brilliant!  I used to suffer through this via an iteration of git blame and git show to the point of custom bash scripts.

One thought on “git: history of a source code line”

Leave a Comment