Git Blame Can Do More


Hi Friends,

Today, we’re diving into the often under-appreciated git blame.

Often used to find out who last modified a line of code, git blame has several powerful features. Let’s explore some of these hidden gems, particularly focusing on the flags:

  • -w
  • -C
  • -C -C
  • -C -C -C

Ignoring Whitespace with the -w Flag

Do you know the annoying blame results showing over an indent or a space removed / added?
"-w" fixes that!

git blame -w file_name

And you got yourself a clean blame with the real authors of changes.

Ignoring Code Movements With -C Flag

The -C flag takes it a step further. It detects lines that were copied or moved from other files in the repository!
This is particularly useful in large projects where code refactoring and file splitting or merging are common:

git blame -C file_name

To extend the detective work, using -C -C instructs Git to examine not just the target blame file but also to look at other potential sources in the repository:

git blame -C -C file_name

The double -C makes git blame even more robust against file shifts and reorganizations, tracking down code origins through multiple levels of file history.

Maximum Traceability with -C -C -C

Finally, -C -C -C expands the search scope to its maximum:

git blame -C -C -C file_name

Triple -C helps in scenarios where significant portions of a codebase have been moved around multiple times, potentially across multiple files over an extended period. It ensures that you can trace back to the initial commits affecting the current state of any line of code.


git blame is more than just a tool for finding who wrote a line of code; it’s a gateway to the history and evolution of your project. I’ve been using it extensively recently and learned a lot about changes made over periods of time.

Since many code changes are 'obfuscated' over time because of small changes, formatters, and re-orgs, we're left with a hard-to-follow chain of events. Knowing how to remove these layers has been super helpful trying to understand code authors and why/how things were done.

Thanks for reading, have a great weekend!

Whenever you’re ready, here’s how I can help you

ESPRESSO FRIDAYS

Every once in a while I send hand picked things I've learned. Kind of like your filter to the tech internet. No spam, I promise!

Read more from ESPRESSO FRIDAYS

Thank you to our sponsors who keep this newsletter free to the reader: Aikido is your no-nonsense DevSecOps platform. One central system that shows you what matters and how to fix it, from code to cloud. So you can get back to building. Try Aikido today! We’ve all been there – that heart-stopping moment when you realize you’ve accidentally exposed sensitive information. Today, I’m sharing a personal story and introducing a tool that could save you from a similar nightmare. The Nightmare...

Hi friends! Today we’re diving deep into improving your terminal history management. Exploring techniques that can transform your command line experience from frustrating to fluid. Whether you’re a CLI novice or a terminal titan, these methods will boost your productivity and smoothen your workflow. To do that, we’ll explore three levels of terminal command management, from basic to advanced. Not actually running on my phone 😅 1. Basic: Built-in (mostly unused) tooling: Even without...

Hi friends, Tmux is a fantastic tool for managing terminal sessions, but it has its limitations. One major drawback is the lack of a floating pane feature, which can make navigating between different panes cumbersome and inefficient. Me frustrated with Tmux lack of floating panes while Zellij is killing it... Most users workaround this by creating new Tmux windows or panes, or by using hidden splits to zoom in and out. These methods work but can be inefficient and require many keystrokes,...