Git protip: blame, please don’t!
By Maxime Bréhin • Published on 10 October 2022 • 1 min

Cette page est également disponible en français.

For goodness’ sake 🙏, tell me you don’t use git blame! Apart from its implied intent, that command will not display the information you’re looking for, but worse, you’re probably going to misinterpret it and go heckle an innocent colleague (adding insult to injury 😡).

What does this command do? It shows what revision and author last modified each line of a file but without displaying what changed!

This means that your colleague may have removed whitespaces or reindented the lines you were analyzing, so they ’re not the author of the bug you found. And you’ll look like an idiot when it turns out it was you who failed and actually introduced the bug.

This brings us to the correct approach: tracking changes to the line range with git log -L. There are other options like -S or -G you may be interested in. You can learn more about it in that other article.

Want more tips and tricks?

We’ve got a whole bunch of articles, and more to come. Also check out our 🔥 killer Git training course: 360° Git!