Git: Who has modified this line?

Solution 1:

To see commits affecting line 40 of file foo:

git blame -L 40,+1 foo

The +1 means exactly one line. To see changes for lines 40-60, it's:

git blame -L 40,+21 foo

OR

git blame -L 40,60 foo

The second number can be an offset designated with a '+', or a line number. git blame docs

Solution 2:

I'd use the git blame command. That's pretty much exactly what it is for. The documentation should get you started.