O'Reilly logo

Pragmatic Version Control Using Git by Travis Swicegood

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Finding Out Who’s to Blame

You’re looking at a file in your project, and one block of code—it might be one line or ten—looks out of place. Or maybe there’s a set of nested conditions that you’re trying to wrap your head around so you can refactor it to make it more understandable.

Looking at the log of a file and differences between revisions can be helpful, but there’s a more useful command when you need information about a particular block of code. git blame prefixes every line with the commit name, committer, and timestamp.

Here are the first two lines of git blame output on hello.html with my last name shortened so the output fits on the page:

 
prompt>​ git blame hello.html
 
^7b1558c index.html (Travis S. 2008-09-21 14:20:21 -0500 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required