It's not exactly what you're asking for, but with git blame <file>
you can see the commit that last modified every line.
The first columns shows the commit ID:
$ git blame my-file.txt
65126918 (David Pärsson 2013-07-22 12:53:02 +0200 1) Heading
c6e6d36d (David Pärsson 2013-07-22 12:53:10 +0200 2) =======
65126918 (David Pärsson 2013-07-22 12:53:02 +0200 3)
13e293e3 (David Pärsson 2013-07-22 12:49:33 +0200 4) Text on first line
8b3d2e15 (David Pärsson 2013-07-22 12:49:49 +0200 5) Text on second line
13e293e3 (David Pärsson 2013-07-22 12:49:33 +0200 6) Text on third line
You can look beyond the last modification by supplying a revision, e.g.
$ git blame 8b3d2e15 my-file.txt
You can also select specific lines with the -L
argument, like this:
$ git blame my-file.txt -L 4,+3
13e293e3 (David Pärsson 2013-07-22 12:49:33 +0200 4) Text on first line
8b3d2e15 (David Pärsson 2013-07-22 12:49:49 +0200 5) Text on second line
13e293e3 (David Pärsson 2013-07-22 12:49:33 +0200 6) Text on third line
More details and clever tricks can be found on the git-blame man page.